© Kathi Fisler, 2007
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 is always moving across the screen. 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. If 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 world.ss teachpack. Work in the "Beginner with List Abbreviations" language level. |
To write this game, you will need to provide at least the following:
A data definition for the "world", which is a single data structure containing all of the information that makes up the current configuration of the game (such as the plane, fires, and water drops and their constituent information). Include all data definitions needed to write your overall world data definition. Do not assume the same number of fires for every use of the game.
A function draw-world
that consumes a world datum
(from the previous item) and produces an image of that world (using
place-image
and empty-scene
as shown in the
world.ss documentation). The place-image
function
produces a scene, so you can nest calls to place-image
to
put multiple objects into a single scene.
A function process-keys
that consumes a world
datum and a key-event (symbol) and produces a new world datum reflecting
changes in the world based on keys pressed.
A function update-world
that consumes a world and
produces a world reflecting what happens when no key is pressed (ie,
the plane continues to move, the water continues to fall, etc).
Once you have these functions, you will run your game using the commands:
(big-bang WIDTH HEIGHT (/ 1.0 28) INITWORLD) (on-redraw draw-world) (on-key-event process-keys) (on-tick-event update-world)where WIDTH, HEIGHT, and INITWORLD are constants you define for the size of the game window and the initial configuration of the game.
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. A fully-working solution to part of the game is better than a non-working solution to the whole game.
You may use whatever images you wish for the pieces of the game
(the ones we used are below; feel free to use them or plain circles
and rectangles if you prefer). We used the built-in (in world.ss)
circle
operator to draw the water drops and the different
sized fire images for different ranges of intensity of fires. You do
not need to reverse the image of the plane when it reverses direction
or do anything fancy with the graphics.
Remove extinguished fires from the world: certain aspects of the game will be much easier to program if you do this.
Raise the intensity of the fire at a much lower rate than you drop it (or the game becomes unplayable). Our prototype raised intensity at 1/100 the rate of lowering it, for example. Use real numbers rather than integers for this.
Use the "insert image" option under the "special" menu to load an
image into your DrScheme file; you can use define to give an image a
name. We used the circle
operator (defined in world.ss)
to get images for the water drops.
Icons are from school-clip-art.com (fire) and clipartguide.com (plane).