public class PoisonGuy { public int radius = 40; int degreeBet = 30; public int x, y; float rotDegree; boolean down; float speed; boolean isAKiller; int killerCount; public boolean alive; float pRed, pGreen, pBlue; float killRcolor, killGcolor, killBcolor; public PoisonGuy(boolean b){ alive = b; } public void pSetup(){ x= width/2; //(int)((Math.random()*200)+(width-250)); y=50; rotDegree=0; down = true; speed = 1; isAKiller = false; killerCount = 0; //FOR TESTING:::: x = (int)(Math.random()*width); y = (int)(Math.random()*height); pRed = 131; pGreen =230; pBlue = 55; killRcolor = 255; killBcolor = killGcolor =0; } public void pDraw(){ pushMatrix(); translate(x,y); rotate(radians(rotDegree)); drawPoison(); popMatrix(); rotDegree+=speed; if(killerCount == 0 || killerCount > 30) moveGuy(); if(isAKiller) { killerCount++; if(killerCount > 80){ isAKiller= false; killerCount = 0; } } } public void killer(){ isAKiller = true; } void moveGuy(){ if(y < (height-(radius/2)) && down) { y++; speed=1; } else { down=false; speed=2; if(y > (radius/2)){ y--; } else { down=true; } } if(x > width-10){ x = 5; } if(x < 0) { x = width-20; } } void drawPoison(){ noStroke(); ellipseMode(CENTER); if(isAKiller){ fill(killRcolor,killGcolor, killBcolor, 255-(killerCount*3)); drawCircles(radius/3+6); } fill(0); drawCircles(radius/3); fill(pRed,pGreen,pBlue); drawCircles((radius/3)-6); } void drawCircles(int n){ for(int i=0;i<=(360/degreeBet);i++){ float tempX = getX((float)(i*degreeBet),radius/2); float tempY = getY((float)(i*degreeBet),radius/2); float m = getSlope(x,y,tempX,tempY); float b = getB(tempX, tempY, m); ellipse(tempX, tempY, n,n); } } float getB(float x1, float y1, float m){ return ((float)(y1 - (m *x1))); } float getSlope(int x1, int y1, float x2, float y2){ return ((float)((y2 - y1)/(x2 - x1))); } float getX(float angle, int radius){ return ((float)(radius * sin(radians(angle)))); } float getY(float angle, int radius){ return ((float)(radius * cos(radians(angle)))); } public void voltPoison(){ if(this.speed < 60) { this.speed++; } } public void makeAKiller(float r, float g, float b){ this.isAKiller = true; this.killRcolor = r; this.killGcolor = g; this.killBcolor = b; } }