Modify a text file: $/practice_ball.pde
$/practice_ball.pde
//// Practice ball hitting guy. float x, y, w=50, h=70; float dx=1, dy=1; String s=""; void setup() { size( 400,300); rectMode(RADIUS); } void draw() { background(255,255,191); fill(0); text( "P to pause.", 10,10); text( s, 10,100); //// Ball fill(0,0,255); ellipse( x, y, 10, 10); // PAUSE, if "P" is last key pressed. if (key != 'P' && key !='p' ) { x = x + dx; y= y + dy; } if (x>400) { dx= -dx; } else if (x<0) { dx = -dx; } if (y>300) { dy= -dy; } else if (y<0) { dy = -dy; } //// Guy if (x>mouseX-w/2 && x
mouseY-h/2 && y
20) { dx = dx/20; } dy *= 3; if (abs(dy)>30) { dy /= 30; } }