/** * Bouncy speed * * Math for artists who now need to program * ITP DriveBy, 10/2/2008 * Elie Zananiri - ez@silentlycrashing.net */ //---------------------------- // variables float currY; int currTime; //---------------------------- void setup() { // set up the applet size(300, 300); smooth(); frameRate(30); // reset the animation independent variable (time) currTime = 0; // set the ball color noStroke(); fill(#FF6F00); } //---------------------------- void draw() { // clear the screen background(0); // move the ball currY = height - move(currTime); // draw the ball ellipse(width/2, currY, 20, 20); currTime++; } //---------------------------- void mousePressed() { // reset the animation independent variable (time) currTime = 0; } //---------------------------- float move(float x) { return 280 * (abs(cos(x / 10.0f)) / (0.006f * (x + 160))) + 10; }