CS 201 - Computer Science I - Fall 2008
Project 3


Loyola College > Department of Computer Science > Dr. James Glenn > CS 201 > Projects > Project 3

Due

Monday, November 10th at 11:59pm. Projects submitted after the due date will be assessed a 20% penalty per day. Projects will not be accepted more than four days late.

Objectives

Assignment


This applet requires Java 2 and so will not work with some browsers.
Use the arrow keys to guide your frogs home.
The supplied code does not do a good job drawing things: the frogs and turtles are simple green ovals, and the logs and vehicles are plain rectanges. Furthermore, the way things are drawn does not convey necessary information to the player: the turtles always look the same whether they are under water or not; and the home bays look the same whether or not they are occupied.

All of the drawing is done by methods in the CalaverasCrossingPainter class. In particular, you will be writing code in the paintFrog, paintHome, paintTurtle, paintLog, paintTractor, paintCar, paintRacecar, and paintTruck methods. Each of those methods is passed four arguments: the Graphics object to use for drawing; the width and height of the area to draw in; and the game element that is being drawn. Check the code to see what identifiers are used for these values.

You should use the Graphics object to draw the game element. The Graphics object you use to draw has been translated so that no matter where the game element is on the screen, you should draw within the rectangle whose opposite corners are at (0, 0), and (width - 1, height - 1). Anything you draw outside this region will not show up on the screen. The Graphics object has also been rotated so that you should always draw the frog facing straight up and the obstacles moving towards the left.

You will have to use methods in the Frog, Turtle, and Home classes to determine how to draw instances of those classes. For example, the Home objects should be drawn differently when they are empty compared to when they are occupied by a frog. (Note that when a frog makes it home and then respawns at the bottom of the screen there is no longer a Frog object in the top row. It is therefore the responsibility of paintHome rather than paintFrog to draw the frogs that have made it home.) You will have to use the documentation to determine which methods to use.

Files

The files needed to play the game are in an archive file. The only source code the archive contains is CalaverasCrossingPainter.java. You should use your CalaverasCrossingWindow.java from Project 2, or download a copy that creates no obstacles if you want to start from scratch. Make sure you do not save the new copy over your P2 code. You should compile and run CalaverasCrossingWindow.java to test your code.

Advice

Grading

Submissions

Submit by e-mail the source code (.java file) for your edited version of CalaverasCrossingPainter.java.