The Lab (in groups of size 2)
You will familiarize yourself with PyGame and the initial source code by adding a
few features. First, the TA will point you to pygame, and
PyGame in Think Like a Computer Scientist.
Then explain the main loop
in wwgame.py and explain the Stage.draw(...) method. They will
outline the class diagram for the supplied classes (without listing all methods and instance variables).
- (No marks)Review all of the code yourself.
- Fix the KeyboardPlayer so that they can not
move off of the stage.
Hint: Each Actor knows the stage
it is on. The KeyboardPlayer needs to ask the stage some questions about it's dimensions.
So take a look at the stage class.
- Modify the KeyboardPlayer so that it does not
move over other Actors.
Do this by having the KeyboardPlayer ask the stage for any Actor in the position it
would like to occupy. If there is an Actor,
this player should stop. We will modify this shortly.
- Modify the KeyboardPlayer again so that when they run into an Actor, they ask them to move. If the other
actor moves out of the way, then the KeyboardPlayer can move into its spot. Otherwise, the
KeyboardPlayer can not move in the specified direction.
- Fix the boxes so that they can be moved, only KeyboardPlayer and other Boxes should be even asking
a Box to move.
- Create new type of Actor, a Wall, these can not be pushed and will not move at all.
Add some Walls to your game.
- Fix the Monsters so that they bounce back when they hit another Actor.
Full marks for doing four of 2,3,4,5,6,7 above. Note that you will have to hand in all of
this as part of the assignment anyway!
References