class Tikk extends Swarm { Vector bud; Lel root; int maxIteration = 0; Tikk(float x, float y) { super(); bud = new Vector(); add(new Lel(x,y,80,PI/5)); root = (Lel)v.firstElement(); bud.add(root); } void display() { Lel la[] = lelArray(); for(int i=la.length; --i>=0;) la[i].display(); } void displaySmooth() { } void react() { for(int i=count(); --i>=0;) { Lel lel = (Lel)v.elementAt(i); lel.tense(0.2); if(mousePressed) lel.avoid(mouseX,mouseY,80,0.04); else lel.avoid(mouseX,mouseY,lel.rad*1.5,0.05); } } void update(float damping) { root.update(damping); } void growBuds(int n) { for(int i=count(); --i>=0;) grow((Lel)v.elementAt(i), n); } void grow(Lel glel, int n) { if(maxIteration==0 || glel.iteration()=0;) { Lel nulel = new Lel(0,0, glel.rad*random(0.70,0.85), glel.tipAngle*random(0.85,1.15)); glel.plugTip(nulel); glel.arrange(); add(nulel); bud.addElement(nulel); } } bud.removeElement(glel); } void nail(float x, float y) { root.nail(x,y); } Lel[] lelArray() { return lelArray(v); } Lel[] lelArray(Vector lv) { Lel la[] = new Lel[lv.size()]; lv.toArray(la); return la; } }