xxxxxxxxxx
36
let nameInput;
let names = [];
let drawShape = false;
let nope = "nope";
let yes = "yes!";
function setup() {
createCanvas(400, 400);
nameInput = select('.name');
nameInput.changed(getName);
frameRate(10);
textSize(32);
background(220);
}
function draw() {
background(220);
for(let i = 0; i < names.length; i = i + 1) {
text(nope,random(width),random(height));
}
if(drawShape == true) {
text(yes,width/2, height/2,100,100);
i=0;
no=0;
}
}
function getName() {
names.push(nameInput.value());
if(nameInput.value() == "tomato") {
drawShape = true;
background(random(255),random(255),random(255));
}
nameInput.value("");
}