Ball ball; void setup() { size(200, 200); smooth(); ball = new Ball(); ball.x = random(width); ball.y = random(height); ball.vx = random(-2, 2); ball.vy = random(-2, 2); ball.s = random(20, 50); ball.col = color(255, 0, 0); } void draw() { background(220); ball.move(); ball.drawShape(); } class Ball { float x; float y; float vx; float vy; color col; float s; void drawShape() { fill(col); ellipse(x, y, s, s); } void move() { x = x + vx; y = y + vy; if (x <= 0 || x >= width) { vx = -vx; } if (y <= 0 || y >= height) { vy = -vy; } } }