xxxxxxxxxx
20
let posX = 200; // var, const
let speedX = 1;
function setup() {
createCanvas(windowWidth, windowHeight);
}
function draw() {
background(220);
posX = posX + speedX;
if (posX < 25 || posX > width-25) {
console.log('bounce');
speedX = speedX * -1;
}
ellipse(posX, 200, 50, 50);
}