xxxxxxxxxx
32
let rSize = 20;
let x = 200;
let y = 200;
let xJump = 4;
let yJump = -3;
let bg = 200;
function setup() {
createCanvas(400, 400);
rectMode(CENTER);
noStroke();
}
function draw() {
background(bg);
ellipse(x,y,rSize,rSize);
x = x + xJump;
y = y + yJump;
if(x >= width-rSize/2 || x <= rSize/2) {
xJump = xJump * -1;
fill(random(255));
bg = random(180,200);
}
if(y >= height-rSize/2 || y <= rSize/2) {
yJump = yJump * -1;
fill(random(255));
bg = random(180,200);
}
}