class Tulip extends PPCircle implements EveryTicker, DropletCollider { int goal; //how many petals til we're done int count = 0; //how many petals at the moment int ttl0; int ttl; AudioSnippet snippet; boolean down=false; Tulip(float x, float y, int totalToBeDone, int leafDurability){ super(35); goal = totalToBeDone; ttl0 = leafDurability; ttl = ttl0; setPosition(x,y); setStaticBody(true); updateImage(); } void updateImage(){ int im = count+1; if(im <1) im = 1; if(im > 9) im = 9; attachImage(loadImage("art/Tulip/small/opening2000"+im+".png")); } boolean showImage; void handleTick(){ /* if(ttl % 10 == 0){ if(showImage){ attachImage(loadImage("art/daisyv2/daisy1.png")); } else { dettachImage(); } showImage = !showImage; }*/ ttl--; if ((count > 0) && (ttl < 1)){ count --; updateImage(); ttl = ttl0; } if (ttl < 1) ttl = ttl0; } boolean shouldRemoveOnDropletCollision(){ return true; } boolean checkDropletCollision(Droplet d){ if(down) return false;; if (isTouchingBody(d)){ count++; ttl = ttl0; updateImage(); int soundNum = count-1; if (soundNum < 1) soundNum = 1; if (soundNum <= 7) { String soundName; if (currentLevel.useAltSounds()) { if (soundNum <= 2) soundName = "sounds/grow_Eb_" + soundNum + ".mp3"; else soundName = "sounds/grow_eb_" + soundNum + ".mp3"; } else soundName = "sounds/grow_f_" + soundNum + ".mp3"; if (snippet != null) snippet.close(); snippet = minim.loadSnippet(soundName); snippet.play(); } if(count == 5){ setRotation(3); down = true; } return true; } return false; } int watercounter = -1; boolean isPouring(){ if(!down) return false; watercounter++; if(watercounter % 20 == 0){ return true; } return false; } boolean isDone(){ return count >= goal; } }