Modify a text file: $/x311ballObject.pde
$/x311ballObject.pde
// x bouncy ball float top, left, wide, high, bottom, right; Ball cue; void setup() { size(600,400); left=100; right=350; wide=right-left; top=50; bottom= height-100; high=bottom-top; // cue = new Ball(); cue.x= left+50; cue.y= top+140; } void draw() { background(200,255,200); fill( 255,255,0 ); rect( left, top, wide, high ); // cue.show(); cue.move(); } class Ball { float x, y; float dx=5,dy=3; //// METHODS // void show() { fill(255,0,0); ellipse( x,y, 25,25 ); } void move() { x += dx; y += dy; // Bounce if (x < left+15) dx = -dx; if (x > right-15) dx = -dx; if (y < top+15) dy = -dy; if (y > bottom-15) dy = -dy; } }