99
CST 112 Project #4
"Dog Race"
(b04a)
Follow the instructions below to write your own (Processing) Java code
for this project.
Submit your code in a file named "p4.pde" in your folder.
- Preliminary version is due next week (11/13 or 11/14), for "code-review".
- Final version is due the following week (11/20 or 11/21),
to be used as the basis of an in-class exam.
Write Java code to define and use these object classes:
Button,
Dog,
Varmit
.
Each instance of these objects should have a global name,
but properties should be defined within the object class
(and global variables should not be used as properties of these objects).
You may start with the code in
p4start.pde
Change the values of the String variables
to give the dogs different names,
and be sure to change the author to contain your own name.
Create a dynamic sketch
as described below.
- Racetrack:
- A racetrack with three parallel tracks (horizontally).
- Dogs:
In each track, a Dog
moves
(a random amount)
whenever its button is clicked.
-
Each dog should be a different color,
and drawn with at least three shapes..
- Buttons:
Four buttons are used to make the dogs move:
- Three buttons have the name of a dog,
and are the same color as that dog.
The fourth button moves ALL three dogs.
- Varmits:
After the race begins, two small varmits
-
run back and forth between the tracks
(bouncing off the ends).
- Messages
- The title and author are displayed on the screen:
When a dog crosses the finish line, the winner's name is displayed.
- Animation:
- Dogs and varmits should all display some sort of animation, as they move.
Screen shot from
p4start.pde
("starter code"),
--
to which you should add your own code.
|
Screenshot from
demo code
.
To view a working demo,
run this code:
demo2 .
|