xxxxxxxxxx
24
let circleX;
let circleY;
let hSpeed = 1;
let vSpeed = 2;
function setup() {
createCanvas(400, 400);
circleX = width/2;
circleY = height/2;
}
function draw() {
background(0);
circleX = circleX + hSpeed;
circleY = circleY + vSpeed;
ellipse(circleX, circleY, 50);
if(circleX >= width - 25 || circleX <= 25){
hSpeed = -hSpeed;
}
if(circleY >= height - 25 || circleY <= 25){
vSpeed = -vSpeed;
}
}