let x = 30 let y = 30 let d = 50 let speed = 4 let speed2 = 5 function setup() { createCanvas(500, 500) noStroke() colorMode(HSB, 100, 100) } function draw() { background(50, 100, 100) x += speed if ((x > 495 - d / 2) || (x < d / 2)) { speed = -speed } y += speed2 if ((y > 495 - d / 2) || (y < d / 2)) { speed2 = -speed2 } fill(30, 100, 100) ellipse(x, y, d, d) }