//MIDTERM EXAM -- CST 112 //Mauricio Ostos, 2014 String title= "Midterm"; String author= "Mauricio Ostos"; String intr= "click one the button twice to make things show up "; String intr2="also if u click on crazy that will activate crazy color and speed up the witch"; float sunX = 0; float moonX =0; float moonY = 100; float dX=0 ; float surface; float sealevel; float birdX = 600; int bgR, bgG, bgB, bgT; float witchX= 100, witchY= 50; float broomX, broomXX, broomY; float chop= 20; float speed=1; float waveX=30, waveY=10; boolean day = false; boolean night=true; boolean crazy = false; float sky; boolean button2=true; boolean button3 = true; boolean button4 = true; boolean button5=true; boolean button6=true; float octoX, octoY, octoDY, octoS; void setup() { //setup size (600, 500); sky=height/4; surface=height/4; sealevel=height; octoX = random(200, width-100); octoY = sky+50; octoDY= 2; octoS = -4; } void draw() { //next frame //button day ,button2 night ,button3 bird,button4 witch, button5 quit , button 6 crazy mode for the witch only work during day time // please press the buttons twice to make them work if (button2) { scene(); grass(); sun(); // text on screen; title, author // fill(0); textSize(14); text( title, width/2-30, 30 ); textSize(12); fill(255); text( author, 20, height-20 ); fill (178, 50, 0); text( intr, width/7, 40); fill (178, 50, 0); text( intr2, width/7, 50); borderSquare(); borderSemicircles(); borderTriangles(); button2(); } else { // text on screen; title, author // night(); water(); waves(); moon(); moonX=moonX+speed; // the speed of the moon moving across the field fill(254, 255, 28); textSize(16); text( title, width/2-30, 30 ); textSize(15); fill(255, 0, 230); text( author, 20, height-20 ); text( intr, 10, 40); text( intr2, 10, 50); octo(); button(); } //else // new button if (button3) { }//if else { bird(); birdX=birdX-3; if (birdX < 0) { // the bird move birdX = 600; } //with move }// else // new button if (button4) { }//if else { witch(); broom(broomX, broomXX, broomY); witchX=witchX-3; if (witchX < 0) { //the witch move witchX = 600; } // witch move } //else // new button if (button5) { // press this to quit the game } else { exit(); } // else // new button if (button6) { } // if else { witch2(); broom(broomX, broomXX, broomY); witchX=witchX-3; if (witchX < 0) { //the witch move witchX = 600; } // witch move Crazy }// else button3();// bird button4(); // witch button5(); // quit button6(); // crazy colors } void scene() { //sky , sea level and crazzy color's background(145, 220, 255); noStroke(); fill(0, 180, 10); rect(0, surface, 800, 600); bgR= int(random(255)); bgG= int(random(210)); bgB= int(random(210)); bgT= int(random(1000000000)); if ( button4 ==true) { fill(bgR, bgG, bgB, bgT); } } void octo() { //move octopus up and down from the ocean surface to the bottom octoY+= octoDY; // move down when octo hits surface// if (octoY< sky+50) { octoDY =+3; } // move up when octo hits bottom// else if (octoY > height-40) { octoDY= -2; } // draw octopus rectMode(CENTER); fill(120, 80, 140); noStroke(); rect(octoX, octoY, 50, 50); ellipse(octoX, octoY-25, 50, 50); // draw tentacles for (float tent= octoX-25; tentwidth) { moonX=0; moonY = random(5, sky-10); } noStroke(); fill(255); ellipse(moonX+40, 45, 60, 60); } void sun() { //sun in top right noStroke(); fill(255, 255, 0); //color of the sun ellipse(sunX+540, 45, 60, 60); //shape of the sun } void bird() { //bird moving right to left noStroke(); fill(180, 20, 180); // color of the bird triangle(birdX, 80, birdX, 100, birdX-30, 90); //head triangle(birdX+15, 65, birdX+15, 115, birdX-10, 90); //body } void witch() { // the head of the witch -- red fill(250, 13, 13); ellipse(witchX, witchY, 26, 26); fill(255, 180, 18); ellipse( witchX - 6, witchY - 2, 5, 5); //head of the witch fill(137, 82, 10); // the body of the witch -- brown rect(witchX - 20, witchY + 13, 40, 60); //body of the witch for (int j=0; j<2; j++ ) { // loops for legs fill (18, 255, 83); rect(witchX-7*j*2, witchY+76, 5, 30); } fill(0); triangle(witchX - 12, witchY - 13, witchX, witchY - 40, witchX + 12, witchY - 13); // the black hat strokeWeight(2); stroke(0); line(witchX - 20, witchY - 13, witchX + 20, witchY - 13); } void witch2() { // the head of the witch -- red fill(bgR, bgG, bgB, bgT); ellipse(witchX, witchY, 26, 26); ellipse( witchX - 6, witchY - 2, 5, 5); //head of the witch // the body of the witch -- brown rect(witchX - 20, witchY + 13, 40, 60); //body of the witch for (int j=0; j<2; j++ ) { // loops for legs rect(witchX-7*j*2, witchY+76, 5, 30); } triangle(witchX - 12, witchY - 13, witchX, witchY - 40, witchX + 12, witchY - 13); // the black hat strokeWeight(2); line(witchX - 20, witchY - 13, witchX + 20, witchY - 13); } void broom( float broomX, float broomXX, float broomY) { broomX= witchX-50; broomXX= witchX+50; broomY= witchY+73; stroke(232, 165, 21); strokeWeight(4); line(broomX, broomY, broomXX, broomY); strokeWeight(1); float broomYY= broomY-10 ; for (int j=0; j<7; j++ ) { line( broomXX, broomYY, broomXX+40, broomYY); broomYY += 3; }// for } // broom void grass() { // tilt grass // float tilt = 40; for (float x=10; x= 75 && mouseX <= 125 && mouseY >= 400 && mouseY <= 450) { // click button 2 button2=!button2; } if (mouseX >= 130 && mouseX <= 185 && mouseY >= 400 && mouseY <= 450) { // click button 3 button3=!button3; } if (mouseX >= 190 && mouseX <= 240 && mouseY >= 400 && mouseY <= 450) { // click button 4 button4=!button4; } if (mouseX >= 245 && mouseX <= 295 && mouseY >= 400 && mouseY <= 450) { // click button 5 button5=!button5; } if (mouseX >= 300 && mouseX <= 350 && mouseY >= 400 && mouseY <= 450) { // click button 6 button6=!button6; } }