float g = 9.8; //gravitational constant float t = 0; //time in seconds float Vx = 10; //velocity along the X axis float Vy = 0; //velocity along the Y axis float x = 20; //x coordinate of the ball's center float y = 20; //y coordinate of the ball's center float diameter = 10; //diameter of the ball int ground = 10; //height of the "ground" above bottom of display float coeff = 0.9; void setup() { size(900,200); background(0); framerate(60); ellipseMode(CENTER); } void draw() { stroke(255); noFill(); line(0, height-ground, width, height-ground); diameter = abs(Vy); Vy = Vy + g*t; y = y + (Vy * t); Vx = Vx; x = x + (Vx * t); t = t + .001; if ( (y + diameter/2) <= (height - ground) ) { ellipse(x, y, diameter, diameter); } else { y = height - ground - diameter/2; ellipse(x,y,diameter,diameter); } if(y+diameter/2 == height-ground) { Vy = (-1 * Vy); Vy = Vy * coeff; } if (x>=width) { noLoop(); } }