2016 November 3,
CS 111: Assignment: Objects
This assignment is intended to help you program with objects. You may work with one partner. Download zombieBetter.py and rename it zombieCustom.py. You will submit this one file electronically, by Monday at the start of class.
First Task: More Zombies
I'd like the simulation to be able to handle more than two zombies. Change the zombies function so that it takes in a positive integer n, and runs the simulation with n zombies. To keep things interesting, these zombies should start with various, randomly chosen positions and velocities. You should not need to alter the Zombie class at all.
Second Task: Panic
Add a "panic button" to the game. When the user presses this button, it teleports the human to a random location in the world, so that perhaps she can spend a few moments zombie-free.
Third Task: A Larger Improvement
The preceding improvements are pretty small. Now let's add a larger feature, that involves alterations to one or more of the classes in zombieBetter.py. I give some suggestions below, but feel free to come up with your own ideas, as long as they are comparable in size and difficulty to mine.
- Place obstacles in the game screen, through which the zombies cannot move. This makes the game's strategy more interesting for the player. Read the inter-object bouncing part of our earthMoonBounce.py, to get an idea of how to implement such obstacles.
- Give the zombies more complicated behavior. A zombie might have a hunger level, that builds up over time, and then abates when the zombie touches a human. The zombie attacks the human only if the zombie is hungry. But what happens to the human when she is touched by a zombie? Is she injured, so that she moves more slowly for a while? Implement several small features like these.
- What if there were additional humans around, other than the one controlled by the player? A non-player human might move randomly, until a zombie started chasing her, at which time she would run away from the zombie. If they zombie caught her, then she would turn into a zombie?
- Maybe the player's character has a gun that fires medicinal darts that cure zombie-ism. Implement this feature, to let the player shoot darts at the zombies, turning them into regular Humans. The player wins the game when she converts all zombies into humans. She loses the game when she gets bitten by a zombie. Carefully tune the number and speed of zombies, to make this challenging but not impossible.
- PyGame isn't just about graphics; it can also play sound. Read the online documentation about PyGame, and try adding some music or sound effects to your game.
- Maybe you don't like zombies, and you want to implement a different kind of simulation or game, that also involves "actors" moving around a screen, but with rather different user controls or artificial intelligence. Feel free.
The game would be better with better graphics, that looked like a human and a zombie, rather than the Earth and the Moon. So you might consider getting some better graphics. But this kind of improvmement is not really educational, so it will not earn credit.
Polish and Submit your Work
Don't forget to polish and test your code thoroughly. It will be graded according to these criteria:
- more zombies (3 points)
- panic button (3 points)
- big improvements (6 points)