float x = 0; float y = 50; float vx = 2; float vy = 2; void setup() { size(200, 100); stroke(255); background(0); smooth(); } void draw() { background(0); ellipse(x, y, 10, 10); if (x > width) { vx = -vx; } if (x < 0) { vx = -vx; } x = x + vx; if (y > height) { vy = -vy; } if (y < 0) { vy = -vy; } y = y + vy; }