// MingQing Peng - Midterm String title= "CST112 MIDTERM"; String author= "MingQing Peng"; String instructions= "q to quit; r to reset; ? for help"; String news= "hahaha~~lets go fishing"; //// GLOBAL DECLARATIONS //// boolean day= true; float surface; float left, right, top, bottom; float x, y, w, h, dx, dy; float sunX, sunY, sunDX=1; float boatX, boatY, boatDX=2, boatDY=0, boatW=100, boatH=20; int boatCounter=0; float fishX, fishY, fishDX=3, fishDY, fishW=60, fishH=20; //boat goes back and forth. schools of fish swim //// Setup: size, reset, etc. void setup() { size( 600,400 ); background(200,250,250); surface= height/4; // Set top,left, etc. top= surface; rectMode(CENTER); reset(); } //// reset: initialize all values; randomize some. void reset() { // Starting positions x= left+10; y=top+50; dx= 3; dy=0; day=true; //fish fishX= 0; fishY= random(20,surface); fishDX= random(1,10); fishDY= 0; fishW= 60 * random(0.5,3.0); fishH= fishW/5; } ////Next frame: scene, boat, octopus, school void draw() { scene(); // Sky and sea; day and night boat(); // Back & forth on surface (always pointing forward). octo(); // Rises slowly (8 legs waving), sinks quickly. school(); // Random number, each slightly smaller, behind, & below. messages(); // Text on screen: title, author, etc. AND a "score" } //// EVENT HANDLERS: mousePressed(), keyPressed() void keyPressed() { if (key == 'q') exit(); if (key == 'r') restart(); if (key == 'd') day(); if (key == 'n') night(); } void mousePressed() { //// Click on boat to stop or start. // +++++ INSERT YOUR CODE HERE ++++ //// Click on octopus to destroy it. // +++++ INSERT YOUR CODE HERE ++++ } //// Check for hits. boolean hit( float x, float y, float xx, float yy, float ww, float hh ) { // Return true if (x,y) is near (xx,yy) boolean result=false; if (x>xx && x right-20){ x= left+20; day= !day; } /** boat: moves back and forth, across the surface. * Red hull points to direction of travel. * Boat stops while fishing. */ void boat() { if (boatX>right || boatXbottom-ah || boatY