xxxxxxxxxx
19
let x = 0;
let xspeed = 3;
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
//x++;
//ball is always moving
x += xspeed;
if (x > width) xspeed *= -1;
//if (x>width || x< 0) zspeed *= -1
else if (x<0) xspeed *= -1;
ellipse(x,height/2,20,20);
}