public class FlyerGuy { public float x, y; float wingFactor; float wingAdd; float fAlpha; public boolean alive; public boolean toKill; float speed; boolean alienDropped; int alienCount; float dropLoc; float fillR, fillG, fillB; public FlyerGuy(boolean t){ alive = t; } public void flyerSetup(){ x=-1500; y=(float)(Math.random()*100 + 60); wingFactor=0; wingAdd=0.6; fAlpha=255; toKill = false; speed=3; alienDropped = false; alienCount=0; dropLoc = (float)(Math.random()*(width-100) + 50); fillR = 234; fillG = 163; fillB = 93; } public void flyerDraw(){ pushMatrix(); translate(x,y); rotate(radians(90)); drawGuy(); popMatrix(); if(x > dropLoc && x <= dropLoc+9) { if(alienCount < 3 && !alienDropped) { dropAliens(); } } updateWings(); moveFlyer(); if(this.toKill) killMe(); } void moveFlyer(){ if(x > width+20) { alienDropped = false; alienCount=0; dropLoc = (float)(Math.random()*(width-200) + 100); x= -900; if(y > height*0.3) y=50; else { y+=30; } } x+=speed; y+=(float)((Math.random()*2)-1); } void dropAliens(){ duplicateAlien(); } void duplicateAlien(){ for(int i=0; i 4) wingAdd*=-1; if(wingFactor < -8) wingAdd*=-1; wingFactor+=wingAdd; } void drawGuy(){ fill(0, fAlpha+20); noStroke(); ellipse(0,-10,25,25+abs(wingFactor)); triangle(-10,-12, -35-wingFactor,-4, -10,12); triangle(10,-12, 35+wingFactor,-4, 10,12); triangle(-10,10, -12,28, 5,10); triangle(-5,10, 12,28, 10,10); //stroke(0); fill(fillR,fillG,fillB, fAlpha+20); rectMode(CENTER); ellipse(0,-10,19,19+abs(wingFactor)); rect(0,0,20,20); stroke(0, fAlpha+20); triangle(-10,-10, -30-wingFactor,-5, -10,10); triangle(10,-10, 30+wingFactor,-5, 10,10); noStroke(); triangle(-10,10,-10,20,0,10); triangle(0,10,10,20,10,10); fill(0); triangle(-9,-8,-20-(wingFactor/2),-4,-9,6); triangle(9,-8,20+(wingFactor/2),-4,9,6); } void killMe(){ fAlpha-=10; y+=8; x-=speed; if(y > height) this.alive = false; if(fAlpha <-10) this.alive = false; } void coolFly(){ x-=speed; } }