// A simple Particle class // Incorporates forces code class Particle { PVector loc; PVector vel; PVector acc; float dia; float timer; float maxspeed; // Color Channels float r; // red float g; // green float b; // blue float a; // alpha // Another constructor (the one we are using here) Particle(PVector l) { acc = new PVector(0,0); vel = new PVector(random(-1,1),random(-1,1)); loc = l.get(); dia = 6.0; timer = 100.0; maxspeed = 2; r = 255; g = 250; b = 82; a = 255; } void run() { update(); render(); } // Method to update location void update() { vel.add(acc); vel.limit(maxspeed); loc.add(vel); acc.mult(0); timer -= 0.5; rockettail(); } // Rocket tail Creator void rockettail() { if (timer >= 51) { g -= 1.8; // r += 6; } if (timer <= 50) { r += 3; g += 3; b += 3; dia += 0.5; } if (timer <= 25) { a -= 8; } } void applyForce(PVector force) { float mass = 1; // We aren't bothering with mass here force.div(mass); acc.add(force); } // Method to display void render() { ellipseMode(CENTER); noStroke(); fill(r,g,b, a); ellipse(loc.x,loc.y,dia,dia); } // Is the particle still useful? boolean dead() { if (timer <= 0.0) { return true; } else { return false; } } }