/*A class to describe a one singular particle*/ class Particle { Vector3D loc; Vector3D vel; Vector3D acc; float r; float timer; //The Constructor (called when the object is first created) Particle(Vector3D a, Vector3D v, Vector3D l, float r_) { acc = a.copy(); vel = v.copy(); loc = l.copy(); r = r_; timer = 100.0; } //look, we can have more than one constructor! Particle(Vector3D l) { acc = new Vector3D(0,0.05,0); //ooooh, bad random, random bad vel = new Vector3D(random(-1,1),random(-2,0),0); loc = l.copy(); r = 10.0; timer = 100.0; } void run() { update(); render(); } //function to update location void update() { vel.add(acc); loc.add(vel); timer -= 1.0; } //function to display void render() { ellipseMode(CENTER); noStroke(); fill(0,100,255,timer); ellipse(loc.x(),loc.y(),r,r); } //is the particle still useful? boolean dead() { if (timer <= 0.0) { return true; } else { return false; } } }