CS 1102 (A12) Homework 2: The Fire Fighter Game

Due: September 6 (Thursday) at 11:59pm via turnin (assignment name hwk2).

Assignment Goals

This homework continues using the graphics framework introduced in Lab 1.

Remember to follow the Expectations on Homework when preparing your solutions, including the academic honesty policy.

The Assignment

Your job is to write a simple interactive game in which the player drops water from a plane onto fires on the ground; the goal of the game is to put out all of the fires by dropping enough water on them. A sample appears to the right.

The plane flies continuously back and forth across the screen (i.e., the plane is always moving, regardless of what the player does). The player can change the direction of the plane by pressing the left and right arrow keys. The player can also drop water from the plane by pressing the down arrow key. Each fire has an intensity: when a drop of water hits a fire, the intensity decreases. As a fire burns without water hitting it, its intensity increases. A fire is extinguished when its intensity reaches zero.

You will build this game using the same image.ss and universe.ss teachpacks used in Lab 1. If you need more documentation, see Worlds and the Universe.

Work in the "Beginning Student with List Abbreviations" language level. (See drop-down menu in lower left corner of DrRacket window.)

To write this game, you will need to provide at least the following:

Once you have these functions, you will run your game using these built-in functions (as you did in lab):

(big-bang INITWORLD
          (on-draw draw-world)
          (on-tick update-world)
          (on-key process-keys))
where INITWORLD is an instance of the world datatype.

You must decide what other functions to implement as part of writing the required functions listed above. However, we expect you to follow the design-recipe strategy used in class in which one function uses one template to operate on one data definition. You may bend this rule for posn's nested within other structures (i.e., you don't need a separate function just to process the posn), but not for other data types you define. Also, if a function consumes two defined data types, pass one one argument directly to a helper function that uses that type's template to operate on it. If you don't follow this design recipe, this assignment will take you far longer than necessary. You'll also lose substantial points in the grading.


If you and your partner prefer to work separately, work out and agree on the data definitions first, then proceed to work on the rest of the code (together or independently).

Implement the game in stages, not all at once. Start with a simple version that lets the user change the direction of the plane's movement, but has no fires or water. Once you have that working, add the water drops and get them to fall. Once that is working, add the fires. Get the fires to decrease in intensity when water hits them, then get them to increase in intensity when no water falls on them.

You will get more credit for a fully-working solution to part of the game than for a non-working solution to the whole game. You should have the game working at least through water drops falling for a passing grade on this assignment.

Hints and FAQs

Our Images

Download the images below (e.g., by right-clicking on the image and "Save Image As" to desktop) and insert it into your file using the "Insert Image" option under the "Insert" menu. (Hint: your code will be more readable if you define constants for the images instead of pasting the image values throughout the definitions.)

small fire medium fire large fire plane [Credits: school-clip-art.com, clipartguide.com]

What to Turn In

Grade your own homework according to General Grading Guidelines before you hand it in!

Turn in a single file hwk2.rkt containing all code and documentation for this assignment. Make sure that both students' names are in a comment at the top of the file.

Back to the Assignments page