/* Eye of the Beast by Ziyad Sattaur Shoot the monster eyes with your laser gun to earn points! */ float man=40; float headY=60; float edge=400; float manEdge=100; float laserY=100; float eyeSpeed = 1; //float character; //float monsterEye; //float laser; //float pointCount; void setup () { //set framerate and canvas size frameRate (30); size (400, 400); } void draw() { //create green grass background background (30, 255, 20); //sky noStroke(); fill (66, 220, 246); rect(0, 0, 400, 40); character(); monsterEye(); //create monster eyelids where eyes pop out from stroke (1); fill (223, 118, 67); triangle (400, 40, 320, 100, 400, 160); triangle (400, 160, 320, 220, 400, 280); triangle (400, 280, 320, 340, 400, 400); } void character() { //create moving character controlled by mouseY stroke (1); fill (255); ellipse (man, headY+mouseY, man, man); strokeWeight(10); line (man, 80+mouseY, man, 160+mouseY); line (man, manEdge+mouseY, manEdge, manEdge+mouseY); stroke(1); line (man, manEdge+mouseY, 20, 140+mouseY); line (man, 160+mouseY, 60, width/2+mouseY); line (man, 160+mouseY, 20, width/2+mouseY); } void monsterEye() { //monster eyes that player shoots at, pop out randomly noStroke (); fill (246, 245, 0); ellipse (edge, 160, 120, 120); ellipse (edge, 280, 120, 120); fill(0); ellipse (edge-60, 160, 10, 30); ellipse (edge-60, 280, 10, 30); edge = edge + eyeSpeed; if (edge < 450) { eyeSpeed = -eyeSpeed; } if (edge > 375) { eyeSpeed = -eyeSpeed; } } void mousePressed() { laser(); pointCount(); } void laser() { //creates laser that player fires at monster eyes strokeWeight(10); stroke(random(0, 255), random(0, 255), random(0, 255)); line(laserY, mouseY+laserY, 350, mouseY+laserY); } /*unable to make following work properly displays "+100points!" regardless of value of mouseY */ void pointCount() { if (mousePressed && mouseY>=40 && mouseY<=80); { print("+100 points!"); } if (mousePressed && mouseY>=160 && mouseY<=220); { print ("+100 points!"); } }