Lab 7 Using Abstractions To Game
Purpose: The purpose of this lab is to practice the use of existing list-processing functions.
Textbook References: Chapter 16.1: Existing Abstractions, Figure 95
The Apple Game
During the course of this lab we will be developing a simple game where apples fall from the sky. The apples accelerate as they fall (as in real life) and you get points for each apple you catch in your basket. You can move the basket by moving your mouse around the screen, but the basket should always stay on the bottom. You can play the game here if you want to see how it works. The game ends after a certain length of time has passed.
Exercise 1 Define some constants to represent the things that do not change during the course of the game.
Exercise 2 Design the data you will need for this program. What changes as the game continues?
Exercise 3 Design the world program. Be sure to use list abstractions whenever possible. In general you should use a list abstraction whenever you are processing a list, but there will be exceptions. Your program should take as input the number of seconds the player has before the game ends.
Updating the game
Exercise 4 Update your game so that in addition to good apples, bad apples can also fall from the sky. Bad apples should be visually distinguishable from good apples in some way. Catching a bad apple in your basket should deduct a point from your score, but you should not be able to have a negative score. What parts of your data definition will have to change to keep track of this new information?
Exercise 5 Update your game so that rocks also fall from the sky (it’s a dangerous world out there). Rocks should crush your basket, rendering it temporarily unusable. The basket should repair itself automatically after some small amount of time (how much time is up to you but the longer you have to wait, the harder your game will be). A crushed basket should be visually distinguishable from a working basket. What parts of your data definition will have to change to keep track of this new information?