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
- Combine the
Player,Asteroid, andBulletclasses from earlier lessons into a single game with one game loop running at 60 FPS. - Display the current score on screen every frame (reuse the
pygame.font/screen.blitapproach from the Collisions lesson). - When an asteroid is destroyed by a bullet, split it into two smaller asteroids (half the
size, each with a new randomdx/dy) if it's above some minimum size, instead of just disappearing, this is the classic Asteroids "splitting" mechanic. - Track a
livescount (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. - 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.