float GRAVITY = .1; class Particle{ Invader i; float x,y,xs,ys; color c; Particle(Invader pi, boolean building){ x = pi.x+(pi.w/2); y = pi.y + (pi.h/2); xs = random(-2,2); ys = random(-2,2 ); c = color(255); if(building && random(100) < 50){ c = GREEN; } } Particle(Tank t){ x = t.x+(t.w/2); y = t.y + (t.h/2); xs = random(-2,2); ys = random(-2,2 ); c = GREEN; } Particle(float px, float py){ x = random(px, px+INVADER_WIDTH); y = random(py, py+INVADER_HEIGHT); c= WHITE; } void move(){ ys += GRAVITY; x += xs; y += ys; if(y > height){ particlesToKill.add(this); } } void draw(){ noStroke(); fill(c); rect(x,y,3,3); } }