CST 111 Exam #1:
"Shooting Fish in a Barrel"
Using the "Processing" PDE,
write a program to do the following:
- Display a rectangular tank (or "barrel")
- A fish swims horizontally, within the barrel from left to right.
- When the fish reaches the right side, "reset" it as follows:
- return to the left side
- set to a random height (between top and bottom of barrel)
- swim to the right at a random speed
- Subtract one point from score when fish reaches right side without being caught!
- At the top of the tank (somewhere near the center) is a gun.
- Clicking on the gun causes it to shoot a black "bullet" downward.
- The 'g' key also does the same thing.
SUGGESTION: code the keyPressed() method first; it's easier!
- If the bullet hits the fish, reset the fish and add 100 points to the score..
- Deduct 5 points from score for every time the gun shoots.
See below for extra features.
For extra credit, add as many as you can.
Be sure to display the SCORE, as well as title and author of your sketch.
Before leaving class, upload to your folder, in file named: "q1-Lastname.java"
EXTRA FEATURES
- Add a second fish, which swims from right to left and has a different color.
- Second fish has same features as first,
but swims in opposite direction
- Be sure to check for bullets hitting both fish (and adjust the score).
- Keep track of total number of hits & misses; display totals beneath the score.
- Add your own creature that slowly moves back and forth along the top of the barrel.
- When you click on the creature, it jumps directly to the gun position and shoots.
- Add a small house and tree, somewhere outside the barrel.
- Add a dead fish at the bottom of the barrel.
TAKEHOME EXAM
Due by noon, Saturday, October 20th
Continue working on (and improving) your code, adding ALL of the EXTRA features (see above).
Upload takehome code to your folder, in a file named: "q2-Lastname.java"
Sample code (for a more-complicated program) is available
here
.
Be sure you understand every line of code that you submit!
Do not copy-and-paste anyone else's code into your own code.