float x, y; //screen position of the particle float vx, vy; //velocity of the particles float ax, ay; void setup() { size(400, 400); stroke(0); strokeWeight(3); fill(150); smooth(); //set position and velocity resetParticle(); } void draw() { background(255); //draw the particle with diameter of 10 ellipse(x, y, 10, 10); /* * update the velocity by adding on the acceleration * remember that acceleration means incremental change * in velocity. */ vx += ax; vy += ay; /* * update the position by adding on the velocity * remember that velocity means incremental change * in position. */ x += vx; y += vy; } // on a mouse click void mousePressed() { resetParticle(); } void resetParticle() { //reset the particle to the middle of the screen x = y = width/2f; //set velocity to 0 vx = vy = 0f; ax = random(-0.01, 0.01); ay = random(0.003, 0.01);//downward }