public class Bugger1 { //**********alien guy float myAlpha; float rotator; public float len, rArm, lArm; public boolean down; public float x,y; float xFactor, yFactor; public boolean alive; public float fillR, fillG, fillB; float mywidth, myheight; int id; public boolean toKill; float sFactor; float scaleVal; public Bugger1(int i, boolean a){ id=i; alive = a; fillR = 240; fillG= 137; fillB= 189; } public void bSetup(){ scaleVal = 0.7; myAlpha = 255; len=40; down = true; rArm = -12; lArm = 42; xFactor = 0; yFactor=2.5; mywidth = width -30; myheight = height-30; rotator=0; toKill=false; sFactor=1; } public void bDraw(){ pushMatrix(); translate(x,y); scale(sFactor); rotate(rotator); scale(scaleVal); drawGuy2(); popMatrix(); updateFeet(); moveXandY(); if(this.toKill) killMe(); } void unheat(){ this.normalizeColor(); if(this.xFactor < 0) this.xFactor = -3; else { this.xFactor = 0; } if(this.yFactor < 0) this.yFactor = -2; else { this.yFactor = 2.5; } } public void normalizeColor(){ if(this.fillR > 240) fillR--; if(this.fillR < 240) fillR++; if(this.fillG > 137) fillG--; if(this.fillG < 137) fillG++; if(this.fillB > 189) fillB--; if(this.fillB < 189) fillB++; } public void heatColor(){ if(this.fillR > 234) fillR--; if(this.fillR < 234) fillR++; if(this.fillG > 93) fillG--; if(this.fillG < 93) fillG++; if(this.fillB > 163) fillB--; if(this.fillB < 163) fillB++; } void heatGuy(){ this.heatColor(); // if(this.yFactor < 0 && this.yFactor > -5) this.yFactor--; // if(this.yFactor > 0 && this.yFactor < 5) this.yFactor++; } void coolGuy(){ this.coolColor(); // if(this.yFactor < -1) this.yFactor++; // if(this.yFactor > 1) this.yFactor--; } public void coolColor(){ if(this.fillR > 249) fillR--; if(this.fillR < 249) fillR++; if(this.fillG > 205) fillG--; if(this.fillG < 205) fillG++; if(this.fillB > 249) fillB--; if(this.fillB < 249) fillB++; } void voltGuy(){ // x+=(float)((Math.random()*4)-2); if(yFactor>1) { yFactor-=0.5; } else { if(yFactor < -1) yFactor+=0.5; } } void moveXandY(){ if(this.y>myheight || this.y<-50) { this.yFactor*=(-1); x+=20; if(this.toKill) this.alive=false; } if(x > width) x-=width; this.x+=this.xFactor; this.y+=this.yFactor; } void updateFeet(){ if(this.down && this.len < 57) { this.len+=0.5; this.lArm-=0.3; this.rArm+=0.3; } else { this.down = false; if(this.len > 38){ this.len-=0.5; this.lArm+=0.3; this.rArm-=0.3; } else { this.down = true; } } } void drawGuy2(){ noStroke(); ellipseMode(CORNER); rectMode(CORNER); //body: fill(0,myAlpha); ellipse(0,0,30,30); rect(0,15,30,15); //legs background: fill(0,myAlpha); triangle(0,30, 5,this.len+5, 13,30); triangle(7,30, 15,this.len+5, 23,30); triangle(17,30, 25,this.len+5, 30,30); fill(fillR,fillG,fillB, myAlpha); //legs: triangle(3,30, 5,this.len, 10,30); triangle(10,30, 15,this.len, 20,30); triangle(20,30, 25,this.len, 27,30); noStroke(); ellipseMode(CENTER); rectMode(CENTER); ellipse(15,15,24,24); rect(15,22, 24,16); fill(0,myAlpha); ellipse(15,15,20,15); } void killMe(){ if(rotator < 90) { rotator+=0.5; myAlpha-=3; sFactor-=0.02; } if(sFactor < 0.1) { this.alive = false; } } }