xxxxxxxxxx
24
let locationX, locationY;
let velocityX, velocityY;
function setup() {
createCanvas(windowWidth, windowHeight);
locationX = width/2.0;
locationY = height/2.0;
velocityX = random(-10, 10);
velocityY = random(-10, 10);
}
function draw() {
background(0);
fill(31, 127, 255);
noStroke();
circle(locationX, locationY, 40);
locationX = locationX + velocityX;
locationY = locationY + velocityY;
if(locationX < 0 || locationX > width){
velocityX = velocityX * -1.0;
}
if(locationY < 0 || locationY > height){
velocityY = velocityY * -1.0;
}
}