2012 May 14,
CS 111: Assignment: Objects
Carleton College, Spring 2012
Prof. Joshua R. Davis, , Goodsell 106B, x4473
This assignment is intended to help you program with objects. You may work with one partner. You will submit your work electronically, in a single file zombies.py. It is due Monday at the start of class.
First Task: Small Improvements
Edit the zombies.py file to make the following minor improvements.
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 be able to make these improvements without altering the Zombie class at all.
Add a "panic button" to the game. When the user presses this button, it knocks all of the zombies away from the user's character, so that the character has some hope of getting away from them for a while.
Second and Third Task: Other Improvements
In the remainder of the assignment, you are invited to make a couple of your own improvments to our zombie "game". 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. To earn full credit, at least two significant improvements should be implemented.
- Place obstacles in the game screen, through which the zombies cannot move. Read the inter-object bouncing part of our simulation.py code, to get an idea of how to implement such obstacles.
- In class, some additional zombie features were suggested. A zombie might have an eyesight range, that determines how close the human must be, before the zombie is attracted to it. 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. (I consider these two improvements together to constitute one "significant" improvement.)
- 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.
- 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? Implement a new Human class for this feature.
- 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.
- 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.
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 test your code thoroughly, and to follow the polishing guidelines described at the end of the Image Processing assignment (no extraneous code, demo section at end, etc.). Submit your work electronically, following the directions at our Technical Issues page, by the start of class on Friday. It will be graded according to these criteria:
- small improvements (3 points)
- one big improvement (3 points)
- another big improvement (3 points)