Build Asteroids using Python and Pygame

Lesson 7 of 7

Final Project: Finish Your Asteroids Game

You now have every piece: a ship that rotates and thrusts, asteroids that drift and wrap around the screen, bullets with a cooldown, and collision detection that awards score and ends the game. Put it all together into a complete, playable game.

Requirements

  1. Combine the Player, Asteroid, and Bullet classes from earlier lessons into a single game with one game loop running at 60 FPS.
  2. Display the current score on screen every frame (reuse the pygame.font/screen.blit approach from the Collisions lesson).
  3. When an asteroid is destroyed by a bullet, split it into two smaller asteroids (half the size, each with a new random dx/dy) if it's above some minimum size, instead of just disappearing, this is the classic Asteroids "splitting" mechanic.
  4. Track a lives count (start at 3). When the player's ship collides with an asteroid, lose a life and respawn the ship at the center of the screen instead of ending immediately, only show "GAME OVER" once lives reach 0.
  5. Add a simple start screen ("Press SPACE to start") shown before the game loop begins updating gameplay.

Stretch goals

  • Make the ship briefly invulnerable (and visually flash) for a second after respawning, so it can't immediately lose another life to an asteroid it spawned on top of.
  • Add a basic sound effect for firing and for an asteroid being destroyed with pygame.mixer.
  • Increase difficulty over time by spawning additional asteroids the longer the player survives.

Submit a link to your finished project (a repo or gist) below, an instructor will review it before you can mark this lesson complete.

This lesson ends in a project. Build it on your own machine, there's nowhere to submit it here, but the brief above is everything you need.