xxxxxxxxxx
26
let x, y;
let Xspeed, Yspeed;
function setup() {
createCanvas(400, 400);
background(220);
x = 50;
y = 250;
Xspeed = 0.1;
Yspeed = 0.1;
}
function draw() {
background(220); // comment out to see how the circle moves
// change location of the circle every frame
x = x + Xspeed;
y = y + Yspeed;
/* every time "draw" function loops, the background and circle are "re-drawn" at a slightly different location, simulating movement*/
circle(x, y, 50);
}