class Trail extends Particle { color c; Trail(color col, PVector pos) { super(pos, new PVector(0,0), TRAIL_LIFE); c = col; } void draw() { float liferatio = life / (float)maxlife; liferatio *= 2; liferatio -= 1; liferatio *= liferatio; liferatio = 1-liferatio; noStroke(); strokeWeight(1); fill(blendColors(c, color(255), life/(float)maxlife)); ellipse(pos.x, pos.y, 10*liferatio, 10*liferatio); } } class Burst extends Particle { color c; Burst(color col, PVector pos, PVector vel) { super(pos, vel, TRAIL_LIFE); c = col; } void draw() { } void tick() { super.tick(); float nvx = vel.x + 0.105* vel.y; float nvy = vel.y - 0.105* vel.x; vel.x = nvx; vel.y = nvy; mote_trails.add(new Trail(c, pos)); } } class Flower extends GameObject { int age; int type; float spin; Flower() { age = 0; boolean collide = false; do { collide = false; pos = new PVector(random(width), random(height)); Iterator fi = flowers.iterator(); while(fi.hasNext()) { Flower f = (Flower) fi.next(); if(inRadius(f.pos, pos, FLOWER_RADIUS*2)) collide = true; } } while(collide); type = nextflower + 1; nextflower++; nextflower %= 3; spin = random(1)+0.5; if(random(1)>0.5) spin = -spin; } void tick() { age++; radius = min(FLOWER_RADIUS * age / FLOWER_RIPEN, FLOWER_RADIUS); if(age > FLOWER_RIPEN && tracing) { if(inRadius(mote_pos, pos, FLOWER_RADIUS)) { //TODO catch effects if(flowertype == 0 || flowertype == type) { removal_flag = true; flowertype = type; flowercount++; combo++; if(combo > MAX_COMBO) combo = MAX_COMBO; if(!muted) getSound.trigger(); int petals = 5; float hr = radius/2; for(int i = 0; i < petals; i++) { float angle = TWO_PI/petals * i + age*0.010*spin; mote_trails.add(new Trail(COLORS[type], new PVector(pos.x + hr*cos(angle), pos.y + hr*sin(angle)))); } } else { if(!muted) hitSound.trigger(); traceRelease(); } } } } void draw() { noStroke(); strokeWeight(1); fill(blendColors(COLORS[0], COLORS[type], 0.3)); if(age > FLOWER_RIPEN) ellipse(pos.x, pos.y, radius, radius); noFill(); strokeWeight(2); stroke(COLORS[type]); int petals = 5; float hr = radius/2; for(int i = 0; i < petals; i++) { float angle = TWO_PI/petals * i + age*0.010*spin; ellipse(pos.x + hr*cos(angle), pos.y + hr*sin(angle), hr, hr); } fill(blendColors(color(255), COLORS[type], 0.5)); ellipse(pos.x, pos.y, radius/3, radius/3); } }