// establish vectors
PVector msize,legs;
//array for leg movement
float [] legList = {
0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5,7,7.5,8,8.5,9,9.5,10
};
void setup(){
//no outline
noStroke();
//new vectors for monster size
msize = new PVector(100,80);
// size for legs
legs = new PVector(msize.x-90,msize.y+50);
size(1000,1000);
};
void draw(){
background(66,66,66);
//runs monster
new monster();
};
// creates class for monster
class monster{
//dimensions of screen / 2
float xp = width/2;
float yp = height/2;
// constrains for ellipse
// elipse will follow mouse, but is constrained to these perimeters
float x = constrain(mouseX, 528.5,565);
float y = constrain(mouseY,522,555);
monster(){
fill(0,0,0);
// monster head
rect(xp,yp,msize.x,msize.y);
fill(255,255,255);
//monster eye
ellipse(xp+50,yp+40,msize.x/2,msize.y-30);
fill(100,0,0);
//monster pupil
// floats x and y are set as mouse co-ordinates, but are constrained to set perimeters
ellipse(x,y,10,25);
//if a button on the keyboard is pressed...(fill the eye with red) create a red elipse in the same perimeters as the white one is, but on top of it (second to be drawn so on top)
if(keyPressed == true){
fill(0,0,0);
ellipse(x,y,10,25);
fill(255,22,55);
ellipse(xp+50,yp+40,msize.x/2,msize.y-30);
}
/* if the mouse is pressed...`
*/
if(mousePressed == true){
// for interger j is less than the length of legList (I think there's like 20 in legList), increase j
for(int j =0; j< legList.length; j++){
fill(0,0,0);
//leg 1...corresponds to looping array
rect(xp+20,yp+80,msize.x-90,legs.y+random(legList[j]));
//leg 2.....also corresponds to looping array
rect(xp+70,yp+80,msize.x-90,legs.y+random(legList[j]));
}}
else{
//otherwise (if mouse is not pressed, if j != 0
fill(0,0,0);
//unmoving leg 1
rect(xp+20,yp+80,msize.x-90,msize.y+50);
//unmoving leg 2
rect(xp+70,yp+80,msize.x-90,msize.y+50);
}
}
}