CST112 -- Graded Project: The Little Red Boat"
For this project, the "sketch" shows a red boat
moving on the surface of the green water, with the sky above.
Whenever the boat completes its journey (from left to right),
the water level falls and a new boat starts a similar journey across the water;
if the level falls to the bottom, the game is over (and you lose!)
However, there will be birds flying in the sky above (at a random heights),
and they may drop "bombs" that can sink the boat.
If a bomb hits the boat, it will stop moving forward (to teh right),
and begin to sink.
Once it hits the bottom, the water level rises
(and another red boat begins its journey from the left).
If the water level reaches its maximum, the game is over, and the player wins.
Coding must be done in a "modular" fashion,
with separate functions ("methods")
performing the various tasks,
and little or no output ro the screen
occurring in the "draw()" method.
For this project, you may freely use "global" declarations
to share information between any "void" methods.
(Methods that return a value, such as a boolean to indicate "hits",
should use only pass-by-value arguments.)
Readability is important,
and will constitute a major portion of the grade for this project.
- SCREEN
- 800 pixels wide by 600 high.
Background should be light blue "sky",
with dark green "water" below the "water line" (see below).
(For the "water"
you may use a dark-green rectangle,
across the entire scree (from x=0 to x=800),
with its top at the water line and its bottom at the bottom of the screen.
For extra credit, you may make "waves" on the surface, using tiny circles
that alternate green and sky-blue.)
- WATER LEVEL
-
Water level starts at 250 (pixels down from top of screen),
and may go up or down.
Each time the boat reaches the end (at x=800),
the water level goes down by 50 pixels.
(You win if it reaches bottom at y=600!)
If time the boat sinks (down to y=600),
the water level goes up by 50 pixels.
If water level reaches the maximum (y<=100), the game is over (and the player loses!)
- BOAT
- The boat should be a red trapeziod,
50 pixels high,
150 pixels along the waterline,
but 200 pixels along the deck
(from the vertical back "stern" to the pointy front "bow".)
Add a small creature on top, if you can.
For extra credit,
you may add thin stripes, indicating which number of boat it is.)
The boat either moves 10 pixels per frame from left to right,
or it sinks at a rate of 5 pixels per frame.
- BIRDS
- A flock of five birds flies (left to right), at a randomly-chosen height,
dropping a "bomb" load whevery you click the mouse.
Birds fly three times as fast as the boat.
A "bird" is a triangle 15 pixels wide and 5 pixels high,
and the upper-left corner of each bird is 15 pixels to the right and 5 pixels below the previous bird.
- BOMBS
- The bomb falls from the leftmost bird,
downward twice as fast as the bird is flying.
If the bomb hits the boat, it explodes (for 5 frames) then sinks.
If the bomb hits the water, it makes a splash (for 5 frames), then disappears.
(If the mouse is clicked while a bomb is falling,
that bomb disappears immediately, and a new bomb starts falling.)
- END-OF-GAME-SCREEN
- Announce the result (win or lose) at the end of the game.
(Also show the number of boats, bombs, etc. if you can.)
- SOME IDEAS FOR ADDITIONAL FEATURES (for extra credit).
-
* Pause the game when "P" or "p" key is pressed. (Any other key continues.)
* Make the boat reverse direction each time (left-to-right, then right-to-left).
(Bow should point in same direction.)
* Make a "splash" when the bomb hits the water.
* Water level rises a little, whenever a bomb splashes (without hitting boat).
Put stripes on the boat to indicate its number.
(Also show the number on the bow)
DOCUMENTATION:
Always begin each program with comment lines that give your name and the project identification,
then briefly says what your code is supposed to do (if it works!)
// Zachary Bloggs, "Red Boat" Project (redBoat.pde):
// Water level rises or falls -- lower if boat reaches shore; higher if it sinks.
Also, add some text to your sketch,
giving your name and providing some sort of title for it.
For example:
text( "Water level drops when boat reaches shor; rises if boat sinks.", 40,10);
text( "Zachary Bloggs", 10,230);
The completed project with the "Processing" sketch file (the ".pde" file)
should be submitted electronically,
by creating a file named "redBoat.pde" in your folder,
and pasting your source code into it.