PROJECT 2
Using the Processing PDE,
create a "sketch" to satisfy
these specifications:
Use separate functions to draw or move each different part of the sketch
calling these functions from your draw()function,
and using the other functions described in the "METHODS" section below.
SCENE
Blue sky above a green sea
(occupying about 3/4 of the window).
within the sky are two buttons and a "score" (see below).
BUTTONS & SCORE
A "GO" button starts up the fishing boat.
A "CATCH" button catches any fish that are below the boat.
The score shows how many fish have been caught, so far.
FISH
Under the sea, three fish swim across the window, from left to right.
When a fish reaches the right side, it disappears then reappears on the left side at a new random height,
and swims to the right with a new random speed.
Each fish should consist of a (different-colored) ellipse, with a triangular tailfin at the back and a round eye at the front.
If possible, give the fish some animation,
such as a flapping middle-fin or a winking eye.
BOAT
On the surface of the sea, a boat begins sailing slowly from left to right
when the "GO" button is clicked.
When the boat reaches the right side, it turns around (pointing the other way!),
and begins moving back to the left side.
When the boat returns to the left side, it disappears
(until the GO button is clicked again.)
If possible, animate theboat,
with a flopping mast and/or bouncing on waves.
CATCHING FISH
When the "CATCH" button is clicked
any fish that is directly underneath the boat gets "caught"
(but the boat does not stop).
When a fish is caught, the score is increased by one
and that fish stops swimming to the right
(and another fish begins from the left, at a random height and speed).
METHODS: Write separate functions to do each of the following tasks:
- Write a void function to draw a rectangular "button".
Arguments should include the (x,y) position of the button, its width and height,
and a String containing some text to be displayed on the button.
(The button will be filled with the current "fill" color".)
- Write a boolean function to return true iff a button is clicked.
Arguments should include the (x,y) position of the button, and its width & height.
- Write a void function to draw one fish.
Arguments should include the (x,y) position of the fish, and a Sting for the name to be displayed on that fish.
(The fish will be filled with the current "fill" color".)
- Write a boolean function to return true iff a fish is directly beneath the boat.
Arguments should include the x-coordiantes of the fish and the boat.
(A fish is "caught" if is X coordinate is within 10 pixels of the boat's X coordinate.
Upload your source code code into your folder, in a file named project2.pde
on or before midnight, Wednesday, March 15th.
There will be an in-class coding exam
on Monday March 20th.
REMEMBER:
Code
readability
is very important.
- Start each method with a comment saying what it does.
- Pick meaningful name for variables.
- Properly indent each
{
block
of
code.
}
- Be sure to display a title at the top sketch and your name near the bottom.
|