xxxxxxxxxx
32
// make ball respawn where it started after it leaves the canvas
// an actual in class demo from my CCL class.
let dia = 50;
let y;
function setup() {
createCanvas(400, 400);
x = width/2;
y = 0;
}
function draw() {
background("violet");
noStroke();
circle(x, y, dia);
console.log("dia", dia) // HERE IS CONSOLE.LOG for dia
y = y + 5;
if (y > width) {
y -= y;
//console.log(y) // HERE IS CONSOLE.LOG for y
}
console.log(y) // HERE IS CONSOLE.LOG for y
}
function mousePressed() {
if (dia < 100) {
dia += 50;
} else {
dia = 50;
}
}