MIDTERM EXAM -- CST 112 (Fall 2012)
In-class portion: Wednesday, October 26
(Take-home portion due October 31)
Using the "Processing" language,
create a "sketch" that meets the SPECIFICATIONS given below.
-
IN-CLASS:
Upload your midterm souce code to your own folder,
in a file named "XYZ-midterm.java"
(where XYZ are YOUR initials, in UPPER CASE).
-
TAKEHOME:
Upload takehome souce code to your folder,
in a file named "XYZ-takehome.java"
(where XYZ are YOUR initials, in UPPER CASE).
SYNTAX:
All code must be syntactically correct;
code that does not compile and run,
will not be accepted.
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.
SPECIFICATIONS
- SCREEN Screen is 700 pixels wide by 500 pixels high.
- The top half of the screen is the
"SKY" [see below]
and the lower 3/4 of the screen is the "OCEAN" [see below].
(The "surface" of the ocean is at height/2.)
BEWARE: Various creatures traverse or lurk within these two regions, and may commit nefarious actions within during the day or night!
- DAYTIME (when the boolean variable "day" is true")
- During the daytime,
the sky is light blue,
a yellow sun appears in the upper-right portion of the sky,
and a "BIRD" [see below]
flies across the sky, from RIGHT to LEFT, every three seconds.
(To move ten pixels per second, at thirty frames per second,
the x value should increase by 0.3 pixels per frame.)
- NIGHTTIME (when the boolean variable "day" is false")
- During the night,
the sky is darker,
a pale-pink moon appears in the MIDDLE of the sky,
The "WITCH" [see below]
flies on her broom, across the night sky,
from RIGHT to LEFT,
every ten seconds,
and the
"OCTOPUS" [see below]
slowly bobs up-and-down,
from the bottom of the sea to the surface.
- WITCH
- The WITCH
consists of a black triangular hat,
a red face,
a brown rectangular body,
and two green legs,
riding on a BROOM
that has seven (7) bristles.
(See image at the right.)
USE A LOOP TO MAKE THE BRISTLES
The WITCH flies across the night sky,
every ten seconds, from RIGHT to LEFT.
When the WITCH passes the moon
(at the center of the screen),
reduce the score by 50 points
(only ONCE per passing).
- The OCTOPUS
slowly bobs up-and-down,
from the bottom of the sea to the surface.
-
The octopus consists of a dark body
shaped like a "mailbox"
with a round top,
(see image),
and eight legs below.
USE A LOOP TO MAKE THE LEGS.
All eight legs should slant, either to the left or to the right, every few frames,
when the octopus is rising,
but go straight downward when the octopus is sinking.
- BIRD:
(flies across the daytime sky,
every three seconds)
-
The bird consists of two large purple triangles.
- FISHES: Three fish, each with a different, bright color,
swim around during the daytime (only).
-
When daytime begins, all three fish all start in the center of the ocean,
then swim away with random velocities
from +7 to -7 pixels per frame in X,
and from
from +5 to -5 pixels per frame in Y.
Each fish consists of an ellipse with a triangular tail at the BACK
(i.e. the tail should be on the LEFT if the fish is swimming to the RIGHT,
and the tail should be on the RIGHT if the fish is swimming to the LEFT.)
TEXT: The following text should also appear on the screen:
- Title at the top center of the screen should say: "CST 112 Midterm"
(or "Takehome")
- At the lower left corner of the screen, display your name.
- Also display a SCORE in the upper-right corner of the screen.
EVENTS:
CLICK:
Clicking causes different effects,
depending upon WHERE the mouse is located.
- Clicking near (within 20 pixels of) the witch changes from night to day.
- Clicking near (within 30 pixels of) the bird changes from day to night.
- Clicking near any fish makes the screen FLASH to the color of that fish (change background for one frame), adds ten points to the score,
and makes that fish disappear.
KEYBOARD:
Respond to certain keys, as follows:
- q: quit.
- r: restart game (and reset score to zero).
- d: change to "day"
- n: change to "night"
CODING STANDARDS
- Begin each file with
with comment lines that give your name and the 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.
- Always begin each function ("method")
with comment lines that give your name and the project identification, 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.