xxxxxxxxxx
34
let circleSize = 50;
let x;
let xSpeed = 3;
let ySpeed = 2;
let col=0;
let colSpeed=1;
function setup() {
createCanvas(windowWidth, windowHeight);
x = width / 2;
y = height / 2;
}
function draw() {
background(220);
fill(col);
circle(x, y, circleSize);
x += xSpeed;
y += ySpeed;
col += colSpeed;
if (x > width - circleSize / 2 || x < circleSize / 2 ) {
xSpeed *= -1;
colSpeed *= -1;
}
if (y > height - circleSize / 2 || y < circleSize / 2) {
ySpeed *= -1;
colSpeed *= -1;
}
}