class Spaceball extends Goon{//////////////////////////////////////// SPACEBALL ///////////////////// boolean closed=true; float eyeHitArea= .18;//Radians float angleMemory=0; int spacing =20; int eyeRad=15; int jaggieCount=50; int turtleCounter=0; int waitTime=20; int moveCounter=0; int moveDuration=10; boolean attacking=false; float attackAngle=0; color attackColor; int wc=0; int count; int totalTime=20; Eyeball north,south,east,west,top,bottom; float turnSpeed=.05; ArrayList rollingQue; Spaceball(Vector3D p){ pos= p.copy(); acc=new Vector3D(0,0); vel=new Vector3D(); rad=150; rollingQue=new ArrayList(); makeEyeballs(); angle=PI/4; HitOnSpaceBall l = new HitOnSpaceBall(-PI/2); rollingQue.add(l); HitOnSpaceBall ll = new HitOnSpaceBall(-PI/2); rollingQue.add(ll); pos.setXY(width/4,height+rad); } void unique(){ if(attacking){ drawMagic(attackColor,attackAngle); }else{ if(north.dead&&south.dead&&east.dead&&west.dead&&top.dead&&bottom.dead){ monsters.remove(this); } if(turtleCounter==waitTime){ closed=false; } if(rollingQue.size()>0){ move(); } else{ turtleCounter++; } } } void move(){ HitOnSpaceBall h = (HitOnSpaceBall) rollingQue.get(0); if(moveCounter==0){ if((abs(TWO_PI+angle-h.angle)%(PI/2))0){ angle+=turnSpeed; } else{ angle-=turnSpeed; } } } else{ moveCounter++; if(moveCounter==moveDuration){ rollingQue.remove(h); vel.setXY(0,0); moveCounter=0; angle=angleMemory; } } } void rotateEyes(float orientation, float moveDirection){ Eyeball temp; //println("orientatoin "+orientation+" ----- moveDirection "+moveDirection); if(abs(abs(orientation-moveDirection)-PI)PI-eyeHitArea){ if(!east.dead){ closed=false; attackAngle=angle-PI/2; attackColor=east.col; attacking=true; } east.dead=true; } else if(abs(eyeHitTest+PI/2)0){ HitOnSpaceBall h=(HitOnSpaceBall) rollingQue.get(0); rotate(angle-h.angle); } float controlPoint = (float)rad*moveCounter/moveDuration; float corrFactor=1.4; bezier(0,rad,controlPoint*corrFactor,rad,controlPoint*corrFactor,-rad,0,-rad); bezier(0,rad,(controlPoint-rad)*corrFactor,rad,(controlPoint-rad)*corrFactor,-rad,0,-rad); line(rad,0,-rad,0); popMatrix(); noStroke(); } void drawPopped(){//////DrawOpenSpaceBall! drawJaggies(); for(int i=0; i<4;i++){ drawWedge(0,0,PI/2*i); } } void drawSparkQue(){ int queSize = rollingQue.size(); stroke(230); noSmooth(); for(int i=0;i3){ curvyTri(bob/slope,bob,c,spineHeight); } stroke(c); noSmooth(); bezier(0,0,0,spineHeight,0,0,bob/slope,bob); bezier(0,0,0,spineHeight,0,0,-bob/slope,bob); } noStroke(); smooth(); popMatrix(); } void curvyTri(float x, float y,color g,int ymax){ color col=color(hue(g),saturation(g),100*x/ymax); fill(col); noStroke(); beginShape(POLYGON); vertex(x,y); bezierVertex(0,ymax,0,ymax,0,ymax/2); bezierVertex(0,ymax,0,ymax,-x,y); bezierVertex(0,ymax/2,0,ymax/2,x,y); endShape(); //ellipse(x,y,20,20); } void drawOpening(){ pushMatrix(); stroke(255); translate(0,-280); rotate(count*PI/2/totalTime); line(-8,0,-8,280); rotate(-count*PI/totalTime); line(8,0,8,280); noStroke(); popMatrix(); } void drawHole(color c){ pushMatrix(); translate(0,-140); rotate(random(-count*PI/2/totalTime,count*PI/2/totalTime)); fill(0); float y = random(0,500); ellipse(0,y,10,10); fill(c); ellipse(0,y+10,4,4); ellipse(0,y-10,4,4); ellipse(10,y,4,4); ellipse(-10,y,4,4); popMatrix(); } void doHicky(float x, float y,float r, float level,color c){ if(level>0){ fill(c); c=color(hue(c)-3,saturation(c)+3,brightness(c)+1); ellipse(x,y,r,r); doHicky(x*1.1+r*r*.09,y+r*1.2,r*.8,level-1,c); doHicky(x*1.1-r*r*.09,y+r*1.2,r*.8,level-1,c); }else{ noSmooth(); stroke(c); line(x,y,x*1.4,y+6); noStroke(); smooth(); } } } class HitOnSpaceBall{ public float angle; HitOnSpaceBall(float a){ angle=a; } } class Eyeball extends Goon{ public color col; public boolean dead=false; Eyeball(color c){ col=c; rad=40; pos=new Vector3D(); } void update(int x, int y,float a){ pushMatrix(); translate(x,y); fill(255); ellipse(0,0,rad,rad); pushMatrix(); rotate(a); fill(col); ellipse(-rad/6,0,rad*.55,rad*.55); fill(0); ellipse(-rad/6,0,rad*.3,rad*.3); popMatrix(); fill(255); ellipse(7,9,8,8); popMatrix(); } }