class Octopus extends Goon{// ********* ********* ********* ********* ********* OCTOPUS ********* //// int legCount=8; int angerSpeed=25; ArrayList legs; float rotationCorrection=0; boolean alreadyJumped; int angerCounter=10; Octopus(Vector3D p){ legs = new ArrayList(); pos= p.copy(); acc=new Vector3D(0,0); vel=new Vector3D(); rad=40; mass=20000; type = OCTOPUS; for(int i=0; i0){ vel=h.pos.copy(); vel.sub(pos); vel.normalize(); vel.mult(angerSpeed); angerCounter-=1; } else{ vel.setXY(0,0); } if(random(1)<.03){ alreadyJumped=true; Vector3D m = new Vector3D(random(10,60),random(0,TWO_PI),true); pos.add(m); rotationCorrection+=random(-PI/2,PI/2); if(pos.x<0){ pos.x+=30; } if(pos.x>width){ pos.x-=30; } if(pos.y<0){ pos.y+=30; } if(pos.y>height){ pos.y-=30; } } } void replaceRoot(Sucker newRoot, Sucker oldRoot,boolean kill){ // println("replace Called"); if(kill){ legs.remove(oldRoot); println("kill Leg"); } else{ for(int i=0; isThreshHold){ Vector3D c=new Vector3D(s,a,true); c.add(pos); child=new Sucker(c,this,s*sRatio,a,o); last = false; } else{ last = true; } } void setFirst(){ first =true; } void unique(){ if(!last){ Vector3D targetPoint=new Vector3D(rad*parentDistance,ang,true); targetPoint.add(pos); Vector3D cPos = child.getPosition(); targetPoint.sub(cPos); targetPoint.mult(k); child.applyForce(targetPoint); } vel.mult(b); } void setCurly(float c){ curlyness=c; if(!last){ child.setCurly(c); } } void checkCollision(){ if(true||!first||last){ if(h.hitWingMan(pos,(int)rad*2)){ if(!first){ oct.retaliate(); } if(last){ parent.setLast(); } parent.adoptGrandkid(child,last); if(first){ if(!last){ child.setFirst(); } // println(last); oct.replaceRoot(child,this,last); } } } } void setLast(){ last=true; } void adoptGrandkid(Sucker c, boolean la){ child = c; if(!la){//if the dying sucker was not last then it is not a null child he is giving... c.setParent(this); } } void setParent(Goon g){ parent = g; } void update(float a){ //println("suck'er face?"); ang=a; checkCollision(); unique(); movement(); render(); if(!last){ child.update(a+curlyness); } } void movement(){ vel.add(acc); pos.add(vel); // angle=vel.heading2D();//don't use it, so no need to calculate it. } void render(){ pushMatrix(); translate(pos.x,pos.y); fill(255); noStroke(); Vector3D cPos; if(!last){ cPos = child.getPosition(); } else{ cPos = parent.getPosition(); } Vector3D v = cPos.copy(); v.sub(pos); rotate(v.heading2D()); ellipse(0,rad/2,rad,rad); ellipse(0,-rad/2,rad,rad); // fill(0); // ellipse(rad/10,rad/2,.8*rad,.8*rad); // ellipse(rad/10,-rad/2,.8*rad,.8*rad); popMatrix(); } }