i made a small change so i could change my font size programmatically.
// changed drawCard()
function drawCard(inst,x,y,wid,hig) {
var p = inst.parent;
var card = inst.parent.card;
var rcol = rarityColors[p.rarity];
//*
if (p.rarity == "God") {
colorMode(HSB);
rcol = color(frameCount*10 % 360,100,100);
}
//*/
card.clear();
//
card.noStroke();
card.fill("#141e1f");
card.rect(0,0,500,700,30);
//
if (p.isEX) {
card.image(card.buf1,0,0,500,350);
} else {
card.image(card.buf1,50,60,400,280);
card.strokeWeight(5);
card.stroke(rcol);
card.noFill();
card.rect(50,60,400,280,10);
}
//
if (p.isEX) {
card.stroke(0);
card.strokeWeight(2);
card.fill("rgba(0,0,0,0.6)");
card.textSize(30);
} else {
card.stroke(rcol);
card.strokeWeight(2);
var nc = color(rcol);
nc._array[3] = 0.2;
card.fill(nc);
card.textSize(30);
}
var w = card.textWidth(p.name)+40;
card.beginShape();
card.vertex(25,15);
card.vertex(15,55);
card.vertex(w,55);
card.vertex(10+w,15);
card.endShape(CLOSE);
//
card.noStroke();
card.fill(rcol);
card.textSize(20);
w = card.textWidth(p.rarity)+35;
card.beginShape();
card.vertex(23,50);
card.vertex(15,75);
card.vertex(w,75);
card.vertex(8+w,50);
card.endShape(CLOSE);
//
card.textSize(30);
card.textAlign(LEFT,CENTER);
card.fill(255);
card.noStroke();
card.text(p.name,32.5,35);
card.textSize(20);
card.fill(0);
card.text(p.rarity,29,62.5);
card.textSize(30);
card.fill(p.hpcol);
card.textAlign(RIGHT,CENTER);
card.text(p.health+" DEF",480,35);
if (inst.health < p.health) {
card.fill("red");
card.text((inst.health-p.health)+" HP",480,65);
}
//
card.fill(255);
card.textAlign(LEFT,TOP);
card.textSize(19);
card.text(p.description,20,355,460);
for (var i = 0; i < p.moves.length; i++) {
card.textAlign(LEFT,TOP);
if (p.moves[i].fontSize) {
card.textSize(p.moves[i].fontSize);
}
card.text(p.moves[i].title+":\n"+p.moves[i].description,26,435+85*i,455,75);
card.textAlign(RIGHT,TOP);
card.textSize(19);
card.text(p.moves[i].cost+" ⚛"/*+" "+p.moves[i].cooldown+"❄"*/,26,435+85*i,455,75);
}
///
card.strokeWeight(5);
card.stroke(rcol);
//card.stroke("#00adbc");
for (var i = 0; i < p.moves.length; i++) {
var hover = mouseRect2(x,y,wid,hig,500,700,20,430+85*i,460,75);
if (hover) card.fill("rgba(255,255,255,0.6)");
else card.noFill();
card.rect(20,430+85*i,460,75,10);
}
///
card.noFill();
card.stroke(rcol);
card.strokeWeight(10);
card.rect(5,5,490,690,20);
///
image(card,x,y,wid,hig);
}
// my actual card
createCard({
name:"Blockyheadman",
rarity:"Legendary",
health:5600,
image:"https://avatars.githubusercontent.com/u/80011716?v=4",
offx: 0,
offy: 0,
description: "A random guy who showed up one day and learned programming from nowhere.",
hpcol: 255,
moves:[{
title:"New Project",
description:"Start yet another project you won't finish, deals 200 ATK over 3 turns",
cost:2,
cooldown:2,
use:function(opp) {
// Deal 200 ATK over 3 turns.
}
},{
title:"Long Gone",
description:"I need a break. Avoid attacks for 2 turns.",
cost:4,
cooldown:3,
use:function(opp) {
// Wait 2 turns here
}
},{
title:"Try a real game engine",
description:"Use Godot? But I like CDO. Flip a coin. if heads, convert to using Godot and deal 800 ATK. If tails, keep using CDO and deal 200 ATK to the other player and 100 ATK to yourself.",
fontSize: 14,
cost:8,
cooldown:4,
use:function(opp,self) {
// Do the damage here
}
}],
});