xxxxxxxxxx
30
let xSpeed = 1;
let ySpeed = 3;
let xLocation = 200;
let yLocation = 200;
let ballColor = "#000000";
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
xLocation+=xSpeed;
yLocation +=ySpeed;
if (xLocation + 25 > 400 || xLocation-25 < 0)
{
xSpeed = -xSpeed;
fill(ballColor);
}
if (yLocation + 25 > 400 || yLocation-25 < 0)
{
ySpeed = -ySpeed;
fill(ballColor);
}
else
{
fill("#ffffff");
}
circle(xLocation, yLocation, 50);
}