// The Ball class class Ball { float x; float y; float r; float xspeed; float yspeed; float ballNumber; Ball(float theBallNumber) { ballNumber = theBallNumber; xspeed = random(-5,5); yspeed = random(-5,5); x = width/2; y = height/2; r = 10; } void go(float theBoxHeight) { render(); update(theBoxHeight); } void render() { noStroke(); fill(0,0,0); // Set ellipse color ellipse(x,y,r,r); // Draw ellipse } void update(float theBoxHeight) { // Radius always decreases back to 10 if it's bigger if (r > 10) { r--; } // Adjust x,y based on speed x = x + xspeed; y = y + yspeed; // Account for bouncing off edges if ((x > width) || (x < 0)) { xspeed = xspeed * -1; r = 30; // Adjust radius when bouncing } if ((y > theBoxHeight) || (y < 0)) { yspeed = yspeed * -1; r = 30; } } }