Ball[] balls = new Ball[10]; void setup(){ size(500,500); fill(255, 0, 0); smooth(); ellipseMode(CENTER); //Create all new Ball objects for(int i=0; i= (width -d/2.0) && vx>0)) vx = -vx; if( sy>= (height-d/2.0) && vy>0.0) vy = -0.9 *vy; } void display(){ fill(c); pushMatrix(); translate(sx, sy); //rotate the ball to the appropriate orientation rotate(angle); if(vx<0){ scale(-1, 1);//horizontal image flip } //draw the body of the ball ellipse(0, 0, d,d); //draw white of the eye fill(255); ellipse(d/4, -d/8, d/4, d/4); //draw the pupil fill(0); ellipse(d/3.2, -d/8, d/16, d/16); popMatrix(); } }