The most advanced implementation of the classic Asteroids arcade game ever created! From simple space shooting to complex strategic gameplay with AI enemies, multiplayer support, and endless replayability.
This project represents the complete evolution of the classic Asteroids game through 4 comprehensive phases, each adding sophisticated features that transform the simple arcade shooter into a modern gaming experience.
- ๐ต Advanced Audio System: Synthesized sound effects and spatial audio
- ๐พ Intelligent AI Enemies: UFOs with hunting behavior and boss battles
- ๐ Wave Progression: Infinite waves with persistent high scores
- ๐จ Enhanced Visual Effects: Thruster flames, trails, screen shake
- ๐ฐ๏ธ Advanced Asteroids: Ice, Metal, Crystal types with mining mechanics
- โก Ship Upgrade System: Resource-based hull, engine, weapon, shield improvements
- ๐ฎ Local Multiplayer: Two-player cooperative gameplay
- ๐ Environmental Hazards: Gravity wells and space anomalies
# Clone the repository
git clone https://github.com/Pascal509/Python_Asteroids_Game.git
cd Python_Asteroids_Game
# Create virtual environment
python -m venv venv
source venv/bin/activate # Windows: venv\\Scripts\\activate
# Install dependencies
pip install -r requirements.txt
# Play the Ultimate Edition
python main_phase4.py
Key | Action |
---|---|
WASD or Arrow Keys | Move spaceship |
Space | Shoot current weapon |
X | Drop bomb |
U | Open upgrade menu |
Esc | Pause/Menu |
R | Restart (when game over) |
Key | Action |
---|---|
IJKL | Move spaceship |
U | Shoot current weapon |
O | Drop bomb |
- โ Basic spaceship movement and shooting
- โ Asteroid spawning and destruction mechanics
- โ Collision detection and screen wrapping
- โ Score system and multiple lives
- File:
main.py
- โ Particle explosion effects
- โ Lumpy, realistic asteroid shapes
- โ Triangular player hitbox visualization
- โ Enhanced collision feedback
- โ Multi-weapon system (Normal, Rapid, Spread, Laser)
- โ Power-up collection (Speed, Shield, Weapon upgrades)
- โ Bomb system with area-of-effect damage
- โ Animated starfield background
- Documentation: README_PHASE3.md
- โ Audio System: Synthesized sound effects and music
- โ AI Enemies: UFO hunters and boss battles
- โ Wave Progression: Infinite difficulty scaling with high scores
- โ Visual Effects: Thruster flames, trails, screen shake
- โ Advanced Asteroids: Ice/Metal/Crystal types with mining
- โ Ship Upgrades: Resource-based customization system
- โ Local Multiplayer: Two-player cooperative mode
- File:
main_phase4.py
| Documentation: README_PHASE4.md
Asteroids_game/
โโโ Game Versions
โ โโโ main.py # Phase 1: Classic Asteroids
โ โโโ main_phase4.py # Phase 4: Ultimate Edition
โ
โโโ Core Systems
โ โโโ constants.py # Game configuration
โ โโโ circleshape.py # Base object class
โ โโโ player.py # Enhanced player with upgrades
โ โโโ asteroid.py # Original asteroid system
โ โโโ shot.py # Projectile system
โ โโโ gamestate.py # Game state management
โ
โโโ Phase 3 Features
โ โโโ effects.py # Basic particle effects
โ โโโ powerup.py # Power-up system
โ โโโ weapon.py # Multi-weapon system
โ โโโ bomb.py # Explosive weapons
โ โโโ background.py # Animated starfield
โ
โโโ Phase 4 Advanced Systems
โ โโโ audio.py # Sound synthesis & management
โ โโโ enemies.py # UFO & boss AI
โ โโโ progression.py # Wave & high score systems
โ โโโ enhanced_effects.py # Advanced visual effects
โ โโโ advanced_asteroids.py# Asteroid types & mining
โ โโโ upgrades.py # Ship customization
โ โโโ multiplayer.py # Local co-op system
โ
โโโ Documentation
โโโ README.md # Main documentation
โโโ README_PHASE3.md # Phase 3 features guide
โโโ README_PHASE4.md # Phase 4 complete guide
โโโ requirements.txt # Dependencies
Experience the complete evolution from simple shooting to strategic resource management and ship upgrades.
Two players work together to survive increasingly difficult waves with shared lives and individual scoring.
Persistent leaderboard system with detailed statistics tracking and wave progression records.
- Python 3.7+
- 2GB RAM
- Integrated graphics
- Python 3.9+
- 4GB RAM
- Dedicated graphics card
- Audio system (optional - fallback available)
pygame>=2.6.1
numpy>=1.21.0 # Optional: for advanced audio synthesis
# Clone repository
git clone https://github.com/Pascal509/Python_Asteroids_Game.git
cd Python_Asteroids_Game
# Set up virtual environment
python -m venv venv
source venv/bin/activate # Windows: venv\\Scripts\\activate
# Install dependencies
pip install -r requirements.txt
# Play different versions
python main.py # Phase 1: Classic
python main_phase4.py # Phase 4: Ultimate Edition
# For contributors
git clone https://github.com/Pascal509/Python_Asteroids_Game.git
cd Python_Asteroids_Game
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
pip install -e . # Editable install for development
- Target FPS: 60 (consistent frame rate optimization)
- Memory Usage: ~50-100MB depending on active effects
- CPU Usage: Single-threaded with efficient object pooling
- Audio Latency: <50ms for responsive sound effects
- Real-time Audio Synthesis: Dynamic sound generation without external files
- Sophisticated AI: Enemy behaviors with pathfinding and prediction
- Particle Physics: Multi-layer visual effects with realistic physics
- Resource Management: Economic system with mining and upgrades
- Multiplayer Coordination: Seamless local co-op implementation
- Object Pooling: Efficient memory management for bullets and particles
- Spatial Partitioning: Optimized collision detection for large object counts
- Frame-rate Independence: Smooth gameplay regardless of system performance
- Dynamic Quality Scaling: Visual effects adapt to system capabilities
- Synthesized sound effects using mathematical wave generation
- Spatial audio with distance-based volume control
- Fallback system for environments without NumPy
- Volume controls for master, SFX, and music
- UFO Hunters: Track player movement with predictive algorithms
- Boss Battles: Multi-phase encounters with unique attack patterns
- Escalating Difficulty: Dynamic spawn rates based on performance
- Behavioral Variety: Each enemy type has distinct movement and combat AI
Ice Asteroids (Blue) โ Ice resources for engine upgrades
Metal Asteroids (Gray) โ Metal for hull reinforcement
Crystal Asteroids (Purple) โ Rare crystals for advanced systems
- Hull Plating: Reduce collision damage area
- Engine Boost: Increase acceleration and top speed
- Weapon Systems: Enhanced damage and new firing modes
- Shield Generator: Extended protective barrier duration
We welcome contributions! Here's how to get started:
- Fork the repository
- Create feature branch:
git checkout -b feature/amazing-feature
- Make changes and test:
python main_phase4.py
- Commit changes:
git commit -am 'Add amazing feature'
- Push to branch:
git push origin feature/amazing-feature
- Create Pull Request
- ๐ New enemy types and AI behaviors
- ๐จ Enhanced visual effects and particle systems
- ๐ต Additional audio effects and music
- ๐ธ New ship types and upgrade paths
- โก Performance optimizations
- ๐ฎ New game modes and features
Complete transformation with audio, AI enemies, progression, visual effects, advanced asteroids, upgrades, and multiplayer
Multi-weapon system, power-ups, bombs, and animated backgrounds
Particle effects, realistic asteroid shapes, enhanced collision detection
Core Asteroids gameplay with movement, shooting, and scoring
This project is licensed under the MIT License - see the LICENSE file for details.
- Atari: Original Asteroids arcade game (1979)
- Pygame Community: Excellent game development framework
- NumPy Team: Mathematical operations for audio synthesis
- Open Source Community: Tools, libraries, and inspiration
CodeWithEzeh - Lead Developer & Architect
- ๐ฎ Game design and core systems
- ๐ค AI enemy behaviors and pathfinding
- ๐ต Audio synthesis and sound design
- ๐จ Visual effects and particle systems
- ๐ฅ Multiplayer implementation
- โก Performance optimization
Built with Python 3.13, Pygame 2.6.1, and NumPy
Experience the ultimate evolution of classic arcade gaming. From simple space shooting to strategic resource management, AI battles, and cooperative multiplayer - this is Asteroids reimagined for the modern era.
-
Create a virtual environment (recommended):
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Run the game:
python3 main.py
Asteroids_game/
โโโ main.py # Main game loop and initialization
โโโ constants.py # Game configuration and constants
โโโ circleshape.py # Base class for circular game objects
โโโ player.py # Player spaceship class
โโโ asteroid.py # Asteroid and spawning system classes
โโโ shot.py # Bullet/projectile class
โโโ requirements.txt # Python dependencies
โโโ README.md # This file
- Large asteroids (radius 60) โ Split into 2 medium asteroids (radius 40)
- Medium asteroids (radius 40) โ Split into 2 small asteroids (radius 20)
- Small asteroids (radius 20) โ Destroyed completely
- Frame-rate independent movement using delta time
- Momentum-based spaceship controls
- Vector-based velocity calculations
- Smooth rotation and movement
- Circle-to-circle collision for precise hit detection
- Player vs Asteroids โ Game Over
- Bullets vs Asteroids โ Asteroid splits/destruction
Game settings can be modified in constants.py
:
# Screen settings
SCREEN_WIDTH = 1280
SCREEN_HEIGHT = 720
# Player settings
PLAYER_SPEED = 200
PLAYER_TURN_SPEED = 300
PLAYER_SHOOT_SPEED = 500
PLAYER_SHOOT_COOLDOWN = 0.3
# Asteroid settings
ASTEROID_MIN_RADIUS = 20
ASTEROID_SPAWN_RATE = 0.8
The game follows object-oriented design principles:
CircleShape
- Base class providing collision detection and sprite managementPlayer
- Handles user input, movement, rotation, and shootingAsteroid
- Individual asteroid behavior and splitting mechanicsShot
- Bullet physics and movementAsteroidField
- Procedural asteroid spawning system
- Bullets may occasionally pass through very small asteroids at high speeds
- No boundary wrapping (objects disappear when leaving screen edges)
- No scoring system implemented yet
- Score tracking and high scores
- Sound effects and background music
- Screen wrapping for player and asteroids
- Power-ups (rapid fire, shield, etc.)
- Multiple lives system
- UFO enemies
- Particle effects for explosions
- Menu system with pause functionality
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Original Asteroids game by Atari (1979)
- Boot.dev for the educational framework
- Pygame community for excellent documentation
- Classic arcade game enthusiasts
CodeWithEzeh
- GitHub: @YourGitHubUsername
- Email: your.email@example.com
Made with โค๏ธ and Python ๐
-
Clone this repository:
git clone <your-repo-url> cd asteroids-game
-
Create a virtual environment:
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install pygame
-
Run the game:
python3 main.py
-
Controls:
- Arrow keys or WASD: Move your spaceship
- Spacebar: Shoot lasers
- ESC: Quit game
- Destroy all asteroids to advance to the next level
- Avoid colliding with asteroids - you only have one life!
- Large asteroids split into medium asteroids when shot
- Medium asteroids split into small asteroids when shot
- Small asteroids are destroyed completely when shot
asteroids-game/
โโโ main.py # Main game loop and initialization
โโโ constants.py # Game constants and settings
โโโ requirements.txt # Python dependencies
โโโ README.md # This file
Feel free to fork this project and submit pull requests for improvements!
This project is open source and available under the MIT License.