Lab 3: The Battle for Ram Aras, Part II
This lab is worth 10 points
In this lab, you will practice:
- Sound playing
- Collision detection
In this lab, you will complete the game The Battle for Ram Aras.
You will implement one additional sprite for the game as a Python / Pygame module: the enemy (
Enemy.py). You will also implement a game file:
game.py that will use the battlecruiser and laser sprites from Lab 1. This game file shall contain the game loop, event handling, collision detection, and rendering of score.
Again, you will use the assets (images) for the game:
assets.zip. You will be using this set of assets for the next lab as well.
EnemyPython class shall:
Be subclasses of
- Load the asset with exception handling
- Have a class constructor
Have and maintain the following member variables:
screen(a copy of the drawing surface)
rect(a "moving collision box")
thePlayer(a copy of the battlecruiser object)
Have a method named
Use the asset
mutalisk.gifif it is alive
Use the asset (change image to)
laser_explosion.gifif it is hit by a laser, and then the sprite shall no longer be displayed, inactivated.
- Be subclasses of
Running the enemy module via
python Enemy.pyshall launch a 800x600 window with a white background, with ten (10) enemies bouncing off the walls, elastic collision.
If a laser is fired, the sound asset
laser.wavshall be played.
If the battlecruiser collides with an enemy, the game is over and the sound asset
- If a laser collides with an enemy on the screen, 100 points is awarded.
- The game score shall be rendered near the upper-left corner of the screen with a font color that is not black!
The dimensions of the window in
game.pyshall be 800x600.
- If the game is over, please give feedback to the player that the game is over (e.g., via "Game Over" message or go to a different screen)
To Play the Game
Submitting the Lab
- It would be wise to maintain a list of fired lasers in the battlecruiser class!