class Star { PVector pos; PVector vel; int life; int gen; Star() { pos = new PVector(random(width-STAR_RADIUS*2)+STAR_RADIUS, -STAR_RADIUS); vel = new PVector(0, 0); life = 3; gen = 0; } void tick() { vel.mult(STAR_DRAG); pos.add(vel); pos.y += STAR_DESCEND; } void draw() { float phase = (pos.x + pos.y + phys_frame*0.1) * 0.2; if(life == 3) fill(255, 255, 192+64*sin(phase)); else if(life == 2) fill(255, 192+64*sin(phase), 0); else fill(255, 64+64*sin(phase), 0); noStroke(); regStar(pos.x, pos.y, STAR_RADIUS, 5, (pos.x*2 + phys_frame)*0.01); } void pop() { if(!muted) popSound.trigger(); if(gen == 1) if(!muted) bonusSound.trigger(); if(gen == 2) if(!muted) bonus2Sound.trigger(); if(gen >= 3) { if(!muted) bonus3Sound.trigger(); impressive = true; } burst(pos.x, pos.y, POP_RADIUS, gen+1); score += gen; } } class BurstLeader extends Particle { color col; BurstLeader(PVector p, PVector v, color c) { super(p, v, BURST_LIFE); col = c; } void tick() { if(phys_frame % 3 == 0) trails.add(new Dust(pos, new PVector(vel.x* 0.5, vel.y * 0.5), col)); super.tick(); } void draw() { fill(255); ellipseMode(RADIUS); stroke(col); ellipse(pos.x, pos.y, 3, 3); } } class Dust extends Particle { color col; Dust(PVector p, PVector v, color c) { super(p, v, TRAIL_LIFE); col = c; } void tick() { super.tick(); vel.mult(0.95); vel.x += random(0.1)-0.05; vel.y += random(0.1)-0.05; vel.y += 0.01; } void draw() { noStroke(); fill(col, 255 * life / maxlife); rect(pos.x, pos.y, 2, 2); } } class NumberDust extends Particle { color col; int val; NumberDust(PVector p, color c, int v) { super(p, new PVector(0, 0), TRAIL_LIFE); col = c; val = v; } void tick() { super.tick(); vel.mult(0.95); vel.y += 0.01; if(pos.x < STAR_RADIUS) pos.x = STAR_RADIUS; if(pos.y < STAR_RADIUS) pos.y = STAR_RADIUS; if(pos.x > width - STAR_RADIUS) pos.x = width - STAR_RADIUS; if(pos.y > height - STAR_RADIUS) pos.y = height - STAR_RADIUS; } void draw() { noStroke(); fill(col, 255 * life / maxlife); textFont(font); textAlign(CENTER, CENTER); text(""+val, pos.x, pos.y); } }