A 2D arcade space shooter built with Python and Pygame: battle waves of aliens, defeat the boss, and climb the high score leaderboard.
Aliens is a 2D arcade game inspired by classic space shooters. The player controls a spaceship that must destroy waves of aliens coming from above. The game is divided into 3 rounds plus a final boss. Once the boss is defeated, the cycle restarts with an increased difficulty level.
The project is designed to be simple, lightweight, and easily extensible: it's a great starting point for anyone learning game development with Pygame.
- 🎮 Flexible controls: play with the keyboard, with the mouse (shooting only), or in hybrid mode.
- 👾 Three alien types:
- Green – moves with side bouncing.
- Gray – moves in a zig-zag pattern.
- Red – shoots projectiles at the spaceship.
- 💀 Final boss with a health bar, laser attacks, and fire bursts.
- 🛡️ Power-ups:
- Shield (S) – absorbs one hit and makes the spaceship invulnerable for 200 ms (flashing effect).
- Rapid fire (R) – reduces shooting cooldown (lasts 10 s).
- Multi-shot (M) – fires 3 bullets in a spread pattern (lasts 10 s).
- 📈 Progressive difficulty: after each boss, alien speed and spawn rate increase.
- 🏆 High score: saves the top 5 scores with the player's name.
- 🔊 Sound effects: synthetic sounds generated dynamically (with
numpy) or custom.wavfiles (optional, not included). - 🎨 Minimalist graphics: colored geometric shapes, no external assets.
Destroy as many aliens as possible, survive the three rounds, and defeat the final boss. Each completed cycle increases the difficulty.
| Action | Keyboard | Mouse |
|---|---|---|
| Move left | ← or A |
— |
| Move right | → or D |
— |
| Shoot | SPACE |
Left click |
| Start game | SPACE (from menu) |
— |
| Restart (after Game Over) | R |
— |
| Confirm name (high score) | ENTER |
— |
Note: movement is keyboard-only; the mouse is used exclusively for shooting. The game supports all combinations: keyboard only, keyboard + mouse, or mouse + keyboard.
| Round | Enemies | Score Required |
|---|---|---|
| Round 1 | Green aliens | 100 points |
| Round 2 | Green + Gray aliens | 200 points |
| Round 3 | Green + Gray + Red aliens | 300 points |
| Boss | Final boss (20 hits) | — |
After defeating the boss:
- The level increases (from 1 to 2, 3, 4…).
- Difficulty increases by 0.1 per level.
- The round score resets, but the total score keeps growing.
- Active power-ups are removed.
| Event | Points |
|---|---|
| Alien kill | +10 |
| Alien off-screen (penalty) | −5 |
| Boss hit | +0 (no points) |
| Power-up | Effect | Duration | How to Obtain |
|---|---|---|---|
| 🛡️ Shield | Absorbs one hit, then 200 ms invulnerability | Until 1 hit | Red aliens (30%), boss (every 10 hits) |
| ⚡ Rapid fire | Cooldown reduced from 250 ms to 150 ms | 10 seconds | Boss (every 15 hits) |
| ✳️ Multi-shot | 3 bullets in a spread pattern | 10 seconds | Boss (every 15 hits) |
- Python 3.8+
- Pygame 2.0+
- (Optional) NumPy – for synthetic sounds
-
Clone the repository:
git clone https://github.com/your-username/aliens.git cd aliens -
Install dependencies:
pip install pygame pip install numpy # optional, for synthetic sounds -
Run the game:
python Aliens.py
By default, the game uses synthetic sounds generated with NumPy. If you want to use custom sounds, place these .wav files in the same folder as Aliens.py:
sparo.wav– shooting soundesplosione.wav– alien explosion soundpowerup.wav– power-up pickup soundgameover.wav– game over soundboss_morte.wav– boss death sound
If these files are missing, the synthetic sounds (or silence) will be used.
aliens/
├── Aliens.py # Main game script
├── LICENSE # MIT License
└── README.md # This file
Note: The
highscore.jsonfile is created automatically at runtime to save your scores.
- Python 3 – Programming language
- Pygame – Library for 2D game development
- NumPy (optional) – Synthetic sound generation
- JSON – High score saving
Contributions are welcome! If you want to improve the game, follow these steps:
- Fork the project.
- Create a branch for your feature:
git checkout -b feature/new-feature
- Commit your changes:
git commit -m "Add new feature" - Push the branch:
git push origin feature/new-feature
- Open a Pull Request.
- Add more alien types (e.g., armored aliens).
- Implement a lives system.
- Add a pause screen.
- Joystick/gamepad support.
- Animated backgrounds and custom sprites.
This project is released under the MIT License. See the LICENSE file for more information.
damarant
If you like the project, leave a ⭐ on the repository!
- To the Pygame community for the excellent library.
- To all players who will enjoy Aliens.