xxxxxxxxxx
44
let words = ["bleat", "fruit", "mouse", "juice"];
let wList = [];
let margin = 40;
let answer;
let size = 54;
function setup() {
createCanvas(420, 620);
answer = random(words).toUpperCase();
}
function draw() {
background(220);
for (let i=0; i<5; i++) {
wList.push(new Square(margin+ i*size*1.2, margin, size, answer[i]));
wList[i].display();
}
}
class Square {
constructor(x, y, s, text) {
this.x = x;
this.y = y;
this.s = s;
this.color = 255;
this.text = text;
}
display() {
rect(this.x, this.y, this.s);
textSize(this.s*0.8);
text(this.text, this.x+this.s*0.2, this.y+this.s*0.8);
}
}
class keyBoard() {
}