MIDTERM (and TAKEHOME) -- CST 112
In-class portion:   Wednesday, March 25
(Take-home portion due April 1)

Using the "Processing" language, create a "sketch" that meets the SPECIFICATIONS given below.

SYNTAX: All code must be syntactically correct; code that does not compile and run is unaccaptable.

CODING STANDARDS: Readability of code is an important grading criteria for both the in-class and the takehome portions. Coding Standards [SEE BELOW] will be strictly enforced on the takehome portion, and credit will be deducted on the takehome portion when they are not followed.


DESCRIPTION

  • A boat goes back and forth on the surface of the sea.
  • Schools of fish swim across, from left to right.
  • An octopus slowly rises from the bottom to the surface, waving all eight tentacles, then descends quickly to the bottom.

  • To stop the boat, click on it; click again to restart it.
  • Click on the octopus to make it disappear.
  • If the octopus hits the boat (at the surface), he "swallows" it and becomes twice as big.

SPECIFICATIONS

WINDOW Your code should work for windows of different sizes, from 400x300 to 800x600..
The top quarter of window is "SKY"; green "SEA" lies beneath:     surface = height/4

SCENE -- NIGHT & DAY:
During the day (when the boolean variable "day" is true"), a yellow sun moves slowly from left to right across a light blue sky.
During night (when the boolean variable "day" is false"), the sky becomes darker and a pale-pink moon moves across; when the moon reaches the right side, a new day begins.

BOAT -- Red rectangle plus triangular "bow" at the front.
Add a small cabin on the deck. Make sure the "front" of the boat (triangular "bow") always points in the direction of travel when the boat turns around.

SCHOOL OF FISH
Each "school" moves across the screen, from left to right. When it reaches the right, satart a new school on the left, with a random number of fish (and, optionally, a random color).
Each fish is slightly smaller (75% or 80%) than the one in front, behind and slightly below it.

OCTOPUS slowly bobs up-and-down, from the bottom of the sea to the surface.
When it reaches the bottom, a new octopus starts from a random location on the bottom (and optionally with a random, purplish color).
The octopus consists of a purplish body shaped like a "mailbox" with a round top, (see image), and eight legs below. USE A LOOP TO MAKE THE LEGS.

OPTIONAL: All eight legs slant, to the left or right, every few frames, when the octopus is rising, but legs are straight downward when the octopus is rapidly sinking.

COLLISIONS:   Boat stops to go fishing; octopus attacks boat.
Click on the boat to stop it (and start fishing); click again to restart it.
When the octopus reaches the surface, if the boat is nearby it disappears (and a new boat starts at the left), and the octopus gets twice as big as it descends to the bottom.

TEXT: The following text should also appear on the screen: KEYBOARD: Respond to certain keys, as follows:
  • d: change to "day"
  • n: change to "night"
  • q: quit.
  • r: restart game (and reset score to zero).
OPTIONAL FEATURES: Additional features you may add, for extra credit on in-class midterm.
For the takehome, add at least HALF of these.
  • Make sun (and moon) rise and set, instead of remaining horizontal.
  • Make the moon a crescent; add rays to the sun.
  • Make each new octopus a random shade of purple, and display its number on it.
  • Make each new school of fish a random color.
  • In each frame, make fish "sparkle" by adding a small random value (0-20) to RGB values.
  • When the boat stops, lower a "net" to catch fish; haul up the net quickly, when it hits bottom.
  • If the net gets near a school of fish, keep track of the number of fish in the school, and add it to a total when the net is raised up (unless the octopus gets the boat, first).
  • Display the total catch on the boat, and add it to the score.
  • Show the boat sinking, when the octopus catches it.
  • Boat becomes smaller after octopus eats it. (Restore full size after one round trip.)

CODING STANDARDS

  • Begin each file with with comment lines that give your name and project identification, then briefly say what your code is supposed to do (when it is debugged! ;^> ).
  • On the screen, display a "title" (at the top of the screen) that identifuies the purpose of your software, and an "author" line at the lower left) that contains your name and the publication date.
  • Begin each function ("method") with comment lines that give your name and the project ID, then briefly says what your code is supposed to do (if it works! :*)
  • Choose meaningful names for symbols (variables, methods, etc.)
  • Comment any code that is non-obvious. (Don't add comments that merely say the same thing the code says. Code adequately says WHAT is being done, so you need not paraphrase is happening; it is more important to say WHY it is being done.

  • Do NOT include any lines of code that you don't understand!