public class SlamGuy { //*********slammer guy public float x, y; int rotator; boolean left; int rotChange; public boolean alive; float xMover, yMover; public float fillR, fillG, fillB; float mywidth, myheight; public boolean toKill; int rotMax; float myAlpha; public boolean bringAlive; public int clonerID; boolean beingCloned; boolean beingAttacked; public SlamGuy(boolean t){ this.alive = t; fillR = 81; fillG= 130; fillB = 10; } public void sSetup(){ this.x=(float)(Math.random()*(width-150)); this.y=100; this.rotator=0; this.rotChange=5; this.xMover = 5; this.yMover = 2; mywidth = width - 50; myheight = height -30; toKill=false; rotMax= 70; myAlpha=255; if(!this.alive) myAlpha = 0; bringAlive = false; beingCloned = false; beingAttacked = false; } public void sDraw(){ pushMatrix(); translate(x,y); if(this.y < (height-100)) normalizeColor(); drawSlammer(); popMatrix(); changeRotator(); if(this.bringAlive) { this.makeAlive(); } else { if(!this.beingCloned) moveSlammer(); } if(this.toKill) this.killMe(); } void moveSlammer(){ if(this.x > mywidth || this.x<0) this.xMover*=(-1); if(this.y > myheight || this.y<0) this.yMover*=(-1); this.x+=this.xMover; this.y+=this.yMover; } void changeRotator(){ if(this.rotator > rotMax){ this.rotChange*=-1; } if(this.rotator < 0-rotMax){ this.rotChange*=-1; } this.rotator+=this.rotChange; } void drawSlammer(){ stroke(0); noStroke(); rectMode(CORNER); ellipseMode(CENTER); fill(0, myAlpha); ellipse(50,0,33,26); ellipse(0,0,33,26); rect(0,-11, 50,22); fill(fillR,fillG,fillB, myAlpha); ellipse(0,0,28,22); ellipse(50,0,28,22); rect(0,-10,50,20); pushMatrix(); stroke(0, myAlpha); translate(0,-10); rotate(radians(this.rotator)); translate(0,10); fill(0, myAlpha); triangle(0,-10, -10,-32, 10,-32); fill(fillR,fillG,fillB, myAlpha); triangle(0,-10, -8,-30, 8,-30); popMatrix(); pushMatrix(); translate(50,10); rotate(radians(this.rotator)); translate(-50,-10); fill(0, myAlpha); triangle(50,10, 40,32, 60,32); fill(fillR,fillG,fillB, myAlpha); triangle(50,10, 42,30, 58,30); popMatrix(); pushMatrix(); translate(50,-10); rotate(radians(0-this.rotator)); translate(-50,10); fill(0, myAlpha); triangle(50,-10, 40,-32, 60,-32); fill(fillR,fillG,fillB, myAlpha); triangle(50,-10, 42,-30, 58,-30); popMatrix(); pushMatrix(); translate(0,10); rotate(radians(0-this.rotator)); translate(0,-10); fill(0, myAlpha); triangle(0,10, -10,32, 10,32); fill(fillR,fillG,fillB, myAlpha); triangle(0,10, -8,30, 8,30); popMatrix(); stroke(0,myAlpha); fill(0, myAlpha); ellipse(0,-10,7,7); ellipse(0,10,7,7); ellipse(50,-10,7,7); ellipse(50,10,7,7); fill(255, myAlpha); ellipse(0,-10,5,5); ellipse(0,10,5,5); ellipse(50,-10,5,5); ellipse(50,10,5,5); } void coolSlammer(){ this.coolColor(); if(rotChange < -1) rotChange++; if(rotChange > 1) rotChange--; if(rotChange < 3 && rotChange > -3) { if(this.xMover>0) this.xMover=3; else { this.xMover=-3; } if(this.yMover > 0) this.yMover=1; else { this.yMover=-1; } } } void coolColor(){ if(!beingAttacked){ if(fillR > 0) fillR--; if(fillR < 0) fillR++; if(fillG > 61) fillG--; if(fillG < 61) fillG++; if(fillB > 245) fillB--; if(fillB < 245) fillB+=5; } } void heatSlammer(){ if(rotChange < 15 && rotChange>0) rotChange++; if(rotChange < 0 && rotChange >-15)rotChange--; if(this.xMover > 0 ) this.xMover = 5; else { this.xMover=-5; } if(this.yMover > 0) this.yMover=2; else { this.yMover=-2; } } void heatColor(){ if(fillR > 252) fillR-=3; if(fillR < 252) fillR+=3; if(fillG > 183) fillG-=2; if(fillG < 183) fillG+=2; if(fillB > 5) fillB--; if(fillB < 5) fillB++; } void normalizeColor(){ if(fillR > 81) fillR--; if(fillR < 81) fillR++; if(fillG > 130) fillG--; if(fillG < 130) fillG++; if(fillB > 10) fillB--; if(fillB < 10) fillB++; } void voltSlammer(){ this.voltColor(); if(rotChange < 15 && rotChange>0) rotChange++; if(rotChange < 0 && rotChange >-15)rotChange--; if(this.xMover>1) this.xMover-=0.2; else { if(this.xMover < -1) this.xMover+=0.2; } if(this.yMover > 1) this.yMover-=0.1; else { if(this.yMover < -1) this.yMover+=0.1; } } void voltColor(){ if(fillR > 81) fillR--; if(fillR < 81) fillR++; if(fillG > 130) fillG--; if(fillG < 130) fillG++; if(fillB > 10) fillB--; if(fillB < 10) fillB++; } public void killMe(){ rotMax=18000; if(rotChange < 50 && rotChange>0) rotChange+=5; if(rotChange < 0 && rotChange >-50)rotChange-=5; myAlpha-=8; if(myAlpha <= 0) this.alive = false; xMover=0; yMover=0; } void bringtolife(int id, float locX, float locY){ this.bringAlive = true; this.alive=true; myAlpha = 0; this.x=locX; this.y=locY; this.rotator=0; this.rotChange=5; clonerID = id; this.xMover = (int)(Math.random()*4)+1; if(this.xMover == slammer[clonerID].xMover) { this.xMover+=1; } this.yMover = (int)(Math.random()*2)+0.5; mywidth = width - 50; myheight = height -30; toKill=false; rotMax= 70; slammer[clonerID].beingCloned = true; } public void makeAlive(){ myAlpha+=5; if(myAlpha >= 255){ this.bringAlive = false; slammer[clonerID].beingCloned = false; } } }