// Andrew Urrutia // project 8 ball greenUrrutia, blueUrrutia, redUrrutia; void setup() { size (600,450); redUrrutia= new ball(255, 0, 0); blueUrrutia= new ball(255, 250, 0); greenUrrutia= new ball(0, 0, 255); begin(); } void begin() { redUrrutia.difference(); blueUrrutia.difference(); greenUrrutia.difference(); } void draw() { background(200,250,100); drawTable(); drawBalls(); moveBalls(); button(30, 155, 35, 40); } void drawTable() { fill(250); stroke(150,50,50); strokeWeight(55); rect(60,55,400,350); // table } void drawBalls() { greenUrrutia.show(); blueUrrutia.show(); redUrrutia.show(); } void moveBalls() { greenUrrutia.move(); blueUrrutia.move(); redUrrutia.move(); } class ball { color c; float x=155, y=315; float dx=4, dy=4; // Constructors ball( float x0, float y0 ) { x= x0; y= y0; } ball( int r, int g, int b ) { // color c= color( r, g, b ); } Ball ( ) { } } // method // void move() { // balls moves all over the table // x= x + dx; y= y + dy; // keep balls on screen in table if (x < width-425) { dx= -dx; x= x+ dx; } if (x > width-100) { dx= -dx; x= x + dx; } if (y > 325){ dy= -dy; y= y + dy; } } void show() { fill(c); noStroke(); ellipseMode(CENTER); ellipse(x, y, 25, 25); } void difference() { x= 100 + random(200); y= 100 + random(150); dx= 1 + random(3); dy= 1 + random(2); } // interactive void button( float x, float y, float w, float h) { fill(0); rect(30, 155, 25, 35); if (mousePressed) { if (mouseX>x && mouseX y && mouseY