//This is the making of the monster/squeeble class squeeble { // float xpos; float ypos; float esize; //movement variables float diameter; PVector location = new PVector(random(width),random(height)); PVector velocity = new PVector(0,0); PVector acceleration = new PVector(0.001,0.001); float topspeed = 10; //the main body for the sqeeble squeeble(float howbig){ diameter = howbig; esize = howbig/1.7; } //draw monster void updateMonster(){ xpos = location.x; ypos = location.y; //monsterbody fill(0); ellipse(xpos,ypos,diameter,diameter); //spikies surrounding body spikies fuzz = new spikies(xpos,ypos,1,diameter); fuzz.updateSpikes(); //eyes eye eye1 = new eye(xpos-(esize/2),ypos,esize,2,2); eye eye2 = new eye(xpos+(esize/2),ypos,esize,2,2); //make the eyes look eye1.updateEye(); eye2.updateEye(); } //movement classes //move function void move(){ PVector mouse = new PVector(mouseX,mouseY); //run away from mouse vector PVector dir = PVector.sub(mouse,location); //run away from mouse direction dir.normalize(); dir.mult(-5); acceleration = dir; velocity.add(acceleration); velocity.limit(topspeed); location.add(velocity); } //if it hits the edge it will do this. ie: bounce off the edges void checkedges(){ if (location.x > width-10) { location.x = width-10; velocity.x *= -4; } else if (location.x < 10) { location.x = 10; velocity.x *= -4; } if (location.y > height-10) { location.y = height-10; velocity.y *= -4; } else if (location.y < 10) { location.y = 10; velocity.y *= -4; } } } //these are eyes class eye{ float xpos,ypos; //positions relative to the squeeble body float xp,yp; float eyesize; float angle = 0.0; //position of eye x,y; whitespace size; position of pupil px,py eye(float x, float y, float whitesize, float px, float py){ xpos = x; ypos = y; xp = px; yp = py; eyesize = whitesize; } void updateEye(){ pushMatrix(); translate(xpos,ypos); //white space stroke(255); fill(255); ellipse(0,0,eyesize,eyesize); //pupil angle = atan2(mouseY-ypos, mouseX-xpos); //the angle from the center of the white to the mouse position rotate(angle); //rotate it to the angle stroke(0); fill(0); ellipse(eyesize/4,0,eyesize/3,eyesize/3); //draw the pupil popMatrix(); } } class spikies{ //fuzzies around body float r; float xpos; float ypos; float r1; spikies(float x, float y, float rPoop, float howbig){ r = rPoop; xpos = x; ypos = y; r1 = howbig/3; // distance from origin } float c = r/sqrt(r); float deg = 137.5; //number of spikes float j=1; //draw spikes void updateSpikes(){ pushMatrix(); translate(xpos,ypos);//puts spikes around squeeble body float r2 = r1 * 2.5; //how long the spikes are //draws the spikies around body, for(int i = 0;i<360;i++) { beginShape(); vertex(cos(i-0.02)*r1,sin(i-0.02)*r1); vertex(cos(i+random(-0.1,0.1))*r2,sin(i+random(-0.1,0.1))*r2); endShape(CLOSE); } popMatrix(); } }