Space Defender is a simple arcade-style space shooter game where you protect Earth from incoming space junk.
Your mission is to defend Earth from dangerous space debris. If too much space junk hits Earth or if you collide with space junk yourself, the game ends.
- Left Arrow: Move your spaceship left
- Right Arrow: Move your spaceship right
- Space: Shoot bullets
- R: Restart the game after Game Over
- Player Spaceship: You control a spaceship at the bottom of the screen.
- Earth: Represented by a bar at the bottom of the screen. Earth has 100 health points.
- Space Junk: Random debris that falls from the top of the screen. Larger pieces do more damage to Earth if they hit.
- Score: You earn 10 points for each piece of space junk you destroy.
- The game ends if:
- Earth's health reaches 0
- Space junk hits Earth 3 times
- Your spaceship collides with space junk (unless you have a shield)
When you destroy space junk, there's a 20% chance of a power-up appearing. There are three types of power-ups:
- Double Bullets (Blue): Shoot two bullets at once for 5 seconds
- Speed Boost (Yellow): Increases your spaceship's movement speed for 5 seconds
- Shield (Green): Protects your spaceship from collisions for 5 seconds
The game displays important information:
- Score (top left)
- Earth Health (top left, with health bar at top right)
- Junk Hits counter (shows how many pieces of junk have hit Earth)
- Junk Count (shows current/maximum junk on screen)
- Active power-ups (bottom right corner)
- Ensure you have Python and Pygame installed
- Run the game with
python space_defender.py
- Prioritize destroying larger pieces of space junk as they do more damage to Earth
- Collect power-ups to gain temporary advantages
- Try to keep the number of junk objects on screen manageable
- Watch out for your spaceship's position - avoid collisions!
Good luck defending Earth, Space Defender!