class ball { int x; // position X of the ball int y; // position y of the ball int d; // diameter of the ball int r; //radius of the ball int speedX; // speed of the ball X int speedY; // speed of the ball Y color colorC; //- the color int topBound; //- the top boundary of the ball int bottomBound;//- the bottom boundary of the ball int leftBound; //- the left bound of the ball int rightBound; //- the right bound of the ball ball() { d=10; r=d/2; x=width/2; y=height/2; speedX=4; speedY=3; colorC=color(int(random(0, 255)), int(random(0, 255)), int(random(0, 255))); topBound=y-r; //- the top boundary of the ball bottomBound=y+r;//- the bottom boundary of the ball leftBound=x-r; //- the left bound of the ball rightBound=x+r; //- the right bound of the ball } void render() { fill(colorC); circle(x, y, d); } void move() { x+=speedX; y+=speedY; } void resetBoundaries() { topBound=y-r; //- the top boundary of the ball bottomBound=y+r;//- the bottom boundary of the ball leftBound=x-r; //- the left bound of the ball rightBound=x+r; //- the right bound of the ball } void bounce(){ if (bottomBound>=height) { speedY=-abs(speedY); } if (topBound<=0) { speedY=abs(speedY); } } }