float x, y; //screen position of the particle float vx, vy; //velocity of the particles 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 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 new random velocity vx = random(-0.39, 0.1); vy = random(-0.1, 0.21); }