xxxxxxxxxx
36
let num = 0;
let backgroundColor;
function setup() {
createCanvas(400, 400);
textSize(25);
backgroundColor = color(255, 0, 0);
}
function draw() {
background(backgroundColor);
switch (num) {
case 1:
backgroundColor = color(0, 255, 0);
print("case 1");
break;
case 2:
backgroundColor = color(0, 0, 255);
print("case 2");
break;
default:
print("default state");
}
}
function mousePressed() {
num++;
if (num > 2) {
num = 0;
backgroundColor = color(255, 0, 0);
}
}