//At the Top ArrayList explosions = new ArrayList(); //At the bottom of your draw code drawExplosions(); //To make an Explosion Explode(x, y, number of Sparks, length of explosion); Ex Explode(50, 80, 8, 10); 8 sparks that go for 10 frames located at (50,80) //Paste ALL this at the bottom of your program void drawExplosions() { for (int i =0; i < explosions.size(); i++) explosions.get(i).render(); for (int i =0; i < explosions.size(); i++) { if (explosions.get(i).countdown < 0) explosions.remove(i); } } void Explode(int x, int y, int s, int d) { explosions.add(new Splosion(x, y, s, d)); } class Mover { float x, y; float sx, sy, ax, ay; Mover (float a, float b) { this.x = a; this.y = b; this.sx = 0; this.sy = 0; this.ax = 0; this.ay = 0; } void move() { this.sx += this.ax; this.sy += this.ay; this.x += this.sx; this.y += this.sy; } } class Particle extends Mover { Particle (float x, float y, float sx, float sy) { super(x, y); this.sx = sx; this.sy = sy; } void render() { this.move(); float size = dist(0, 0, this.sx, this.sy); rect(this.x, this.y, size, size); } } class Splosion { Particle[] bits; int[] fades; int countdown; int max; Splosion (float x, float y, int s, int d) { bits = new Particle[s]; fades = new int[s]; for (int i=0; i < s; i++) { bits[i] = new Particle(x, y, -10 + random(20), random(20) - 10); fades[i] = rando(255); } this.max = d; this.countdown = d; } void render() { for (int i=0; i < this.bits.length; i++) { if (this.fades[i] > 0) { fill(255, 255, 255, this.fades[i]); this.bits[i].render(); this.fades[i] --; } } this.countdown--; } } int rando(int n) { return floor(random(n)); }