xxxxxxxxxx
50
// interactive comic examp.
//curent panel saves state of comic.
let currentPanel = 1;
function setup() {
createCanvas(400, 400);
}
function mousePressed() {
currentPanel = currentPanel + 1;
if (currentPanel > 4) {
currentPanel = 1;
}
}
function draw() {
background(220);
// double == means values are equivalent
if (currentPanel == 1) {
// draw the first panel
circle (100, 150, 150);
textSize(35)
text("Hey!", 200, 150)
}
else if (currentPanel == 2) {
// draw the second comic panel
square (10, 100, 100)
textSize(30)
text("What's Your Name?", 200, 100, 50)
} else if (currentPanel == 3) {
triangle(100, 50, 50, 150, 150, 150)
textSize(20)
text("How Are You Today?", 150, 100)
} else if (currentPanel == 4) {
ellipse(100, 200, 100, 40, 100)
text("What Did You Do Today?", 170, 200)
}
}