String title = " Project 9"; String author = "Andrew Urrutia"; float tableColor; Ball greenBall, blueBall, redBall; void setup() { size(600, 500); greenBall= new Ball(0, 255, 0); blueBall= new Ball(0, 0, 200); redBall= new Ball(255, 0, 0); begin(); } void begin() { // changing ball speed greenBall.diffrence(); blueBall.diffrence(); redBall.diffrence(); } void draw() { background(155,130,225); // background color drawTable(); drawBalls(); moveBalls(); button(25, 150, 25, 30); text( title, width/4, 20 ); text( author, 20, height-20 ); } void drawTable() { fill(tableColor); // black stroke(150, 75, 100); strokeWeight(50); rect(100, 55, 350, 355); //table } void drawBalls() { greenBall.show(); blueBall.show(); redBall.show(); } void moveBalls() { greenBall.move(); blueBall.move(); redBall.move(); } class Ball { color c; float x=150, y=300; // Placement of ball float dx=4, dy=4; // speed // constructors Ball( float x0, float y0 ) { x= x0; y= y0; } Ball( int r, int g, int b ) { //different colors c= color( r, g, b ); } Ball ( ) { } void move() { //// Move ball and keep on table x= x + dx; y= y + dy; //traps ball on table if (x < width-430) { dx= -dx; x= x + dx; } if (x > width-150) { dx= -dx; x= x + dx; } if (y < 75) { dy= -dy; y= y + dy; } if (y > 325) { dy= -dy; y= y + dy; } } void show() { //// Draw at (x,y) fill(c); noStroke(); ellipseMode(CENTER); ellipse(x, y, 40, 40); // size of the balls // } void diffrence() { x= 100 + random(200); y= 100 + random(150); dx= 1 + random(4); dy= 1 + random(2); } } // different interactives void button( float x, float y, float w, float h) { fill(5); rect(30, 155, 25, 25); if (mousePressed) { if (mouseX>x && mouseX y && mouseY