Important Note

Tufts ended funding for its Open Courseware initiative in 2014. We are now planning to retire this site on June 30, 2018. Content will be available for Tufts contributors after that date. If you have any questions about this please write to

Tufts OpenCourseware
Author: Ming Y Chow

Tufts OpenCourseWare
Introduction to Game Development
M. Chow
Spring 2012



Lab 3: The Battle for Ram Aras, Part II

This lab is worth 10 points


In this lab, you will practice:

  1. Sound playing
  2. Animation
  3. 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 ( You will also implement a game file: 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: You will be using this set of assets for the next lab as well.


  • The Enemy Python class shall:
    1. Be subclasses of pygame.sprite.Sprite
    2. Load the asset with exception handling
    3. Have a class constructor
    4. Have and maintain the following member variables:
      1. x
      2. y
      3. dx
      4. dy
      5. screen (a copy of the drawing surface)
      6. image
      7. image_w (image width)
      8. image_h (image height)
      9. rect (a "moving collision box")
      10. active (a boolean)
      11. thePlayer (a copy of the battlecruiser object)
    5. Have a method named update
    6. Hethod named draw
    7. Use the asset mutalisk.gif if it is alive
    8. Use the asset (change image to) laser_explosion.gif if it is hit by a laser, and then the sprite shall no longer be displayed, inactivated.
  • Running the enemy module via python shall 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.wav shall be played.
  • If the battlecruiser collides with an enemy, the game is over and the sound asset death_explode.wav is played.
  • 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 shall 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

  • python

Submitting the Lab


  • It would be wise to maintain a list of fired lasers in the battlecruiser class!