xxxxxxxxxx
40
let x;
let y;
let d; // direction
let c; // colour
let r; // radius
let b; // background
let h; //height
function setup() {
createCanvas(400, 400);
x = 30
y = 200
d = +10
c = -255
r = 10
b = 200
h = +3
}
function draw() {
background(0, b ,b);
noStroke()
fill(c)
circle(x, y, r*2);
if (x > r-1 && x < width-r) {
c = c;
d = d
}
else {
c = -c;
d = -d
}
x = x+d
y = y+h
}