xxxxxxxxxx
52
let myString = "";
let mychar;
let mycharArr = [];
function setup() {
createCanvas(600, 600);
}
function draw() {
background(0);
stroke(255);
noFill();
rect(20, 50, 560, 470);
fill("white");
textFont("Courier New", 25);
for (let i=0; i<myString.length; i++){
mycharArr[i].display();
}
}
function keyTyped() {
let lettercheck = key;
if (lettercheck.length == 1){
myString += lettercheck;
mycharArr = [];
let x=25;
let y=80;
for (let i=0; i<myString.length; i++){
if(x >= 560) {
x = 25;
y += 25;
}
mychar = new letter(x,y,myString[i])
mycharArr.push(mychar);
x += 15;
}
}
}
class letter {
constructor (x,y,letter){
this.x = x;
this.y = y;
this.Letter = letter;
}
display(){
text(this.Letter, this.x, this.y);
}
}