Skip to content

A classic Asteroids arcade game built with Python and Pygame. Navigate your spaceship through an asteroid field, shooting asteroids while avoiding collisions.

License

Notifications You must be signed in to change notification settings

Pascal509/Python_Asteroids_Game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ Ultimate Asteroids Game - Complete Evolution

Python Pygame NumPy License Stars

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.

Game Screenshot

๐ŸŽฏ Complete Feature Overview

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.

๐ŸŒŸ Phase 4 - Ultimate Edition (Current)

  • ๐ŸŽต 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

๐Ÿš€ Quick Start - Play Phase 4 Ultimate Edition

# 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

๐ŸŽฎ Complete Control Scheme

Single Player / Player 1

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)

Player 2 (Multiplayer)

Key Action
IJKL Move spaceship
U Shoot current weapon
O Drop bomb

๐Ÿ“ˆ Evolution Timeline

Phase 1: Foundation (Classic Asteroids)

  • โœ… Basic spaceship movement and shooting
  • โœ… Asteroid spawning and destruction mechanics
  • โœ… Collision detection and screen wrapping
  • โœ… Score system and multiple lives
  • File: main.py

Phase 2: Visual Enhancement (Enhanced Graphics)

  • โœ… Particle explosion effects
  • โœ… Lumpy, realistic asteroid shapes
  • โœ… Triangular player hitbox visualization
  • โœ… Enhanced collision feedback

Phase 3: Weapons & Power-ups (Advanced Combat)

  • โœ… 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

Phase 4: Ultimate Edition (Complete Transformation)

  • โœ… 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

๐Ÿ—๏ธ Project Architecture

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

๐ŸŽฏ Game Modes

๐Ÿƒ Single Player Campaign

Experience the complete evolution from simple shooting to strategic resource management and ship upgrades.

๐Ÿ‘ฅ Local Multiplayer Co-op (Phase 4)

Two players work together to survive increasingly difficult waves with shared lives and individual scoring.

๐Ÿ“Š High Score Challenge (Phase 4)

Persistent leaderboard system with detailed statistics tracking and wave progression records.

๐Ÿ› ๏ธ System Requirements

Minimum

  • Python 3.7+
  • 2GB RAM
  • Integrated graphics

Recommended (Phase 4)

  • Python 3.9+
  • 4GB RAM
  • Dedicated graphics card
  • Audio system (optional - fallback available)

Dependencies

pygame>=2.6.1
numpy>=1.21.0  # Optional: for advanced audio synthesis

๐Ÿš€ Installation & Setup

Quick Start

# 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

Development Setup

# 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

๐Ÿ“Š Performance Metrics

  • 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

๐ŸŽจ Key Technical Achievements

Advanced Systems

  • 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

Performance Optimizations

  • 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

๐Ÿ† Features Showcase

๐ŸŽต Audio System (Phase 4)

  • 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

๐Ÿ‘พ AI Enemy System (Phase 4)

  • 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

๐Ÿ›ฐ๏ธ Advanced Asteroid Types (Phase 4)

Ice Asteroids (Blue)    โ†’ Ice resources for engine upgrades
Metal Asteroids (Gray)  โ†’ Metal for hull reinforcement  
Crystal Asteroids (Purple) โ†’ Rare crystals for advanced systems

โšก Ship Upgrade System (Phase 4)

  • 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

๐Ÿค Contributing

We welcome contributions! Here's how to get started:

  1. Fork the repository
  2. Create feature branch: git checkout -b feature/amazing-feature
  3. Make changes and test: python main_phase4.py
  4. Commit changes: git commit -am 'Add amazing feature'
  5. Push to branch: git push origin feature/amazing-feature
  6. Create Pull Request

Contribution Areas

  • ๐Ÿ†• 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

๐Ÿ“œ Version History

v4.0.0 - Ultimate Edition (October 2025)

Complete transformation with audio, AI enemies, progression, visual effects, advanced asteroids, upgrades, and multiplayer

v3.0.0 - Enhanced Combat (October 2025)

Multi-weapon system, power-ups, bombs, and animated backgrounds

v2.0.0 - Visual Upgrade (October 2025)

Particle effects, realistic asteroid shapes, enhanced collision detection

v1.0.0 - Foundation (October 2025)

Core Asteroids gameplay with movement, shooting, and scoring

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • 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

๐Ÿ‘จโ€๐Ÿ’ป Developer

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.

GitHub Download

  1. Create a virtual environment (recommended):

    python3 -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  2. Install dependencies:

    pip install -r requirements.txt
  3. Run the game:

    python3 main.py

๐Ÿ“ Project Structure

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

๐ŸŽฏ Game Mechanics

Asteroid Splitting System

  • 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

Physics

  • Frame-rate independent movement using delta time
  • Momentum-based spaceship controls
  • Vector-based velocity calculations
  • Smooth rotation and movement

Collision Detection

  • Circle-to-circle collision for precise hit detection
  • Player vs Asteroids โ†’ Game Over
  • Bullets vs Asteroids โ†’ Asteroid splits/destruction

๐Ÿ”ง Configuration

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

๐Ÿ—๏ธ Architecture

The game follows object-oriented design principles:

  • CircleShape - Base class providing collision detection and sprite management
  • Player - Handles user input, movement, rotation, and shooting
  • Asteroid - Individual asteroid behavior and splitting mechanics
  • Shot - Bullet physics and movement
  • AsteroidField - Procedural asteroid spawning system

๐Ÿ› Known Issues

  • 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

๐Ÿšง Future Enhancements

  • 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

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • Original Asteroids game by Atari (1979)
  • Boot.dev for the educational framework
  • Pygame community for excellent documentation
  • Classic arcade game enthusiasts

๐Ÿ‘จโ€๐Ÿ’ป Author

CodeWithEzeh


Made with โค๏ธ and Python ๐Ÿ

Installation

  1. Clone this repository:

    git clone <your-repo-url>
    cd asteroids-game
  2. Create a virtual environment:

    python3 -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install dependencies:

    pip install pygame

How to Play

  1. Run the game:

    python3 main.py
  2. Controls:

    • Arrow keys or WASD: Move your spaceship
    • Spacebar: Shoot lasers
    • ESC: Quit game

Game Rules

  • 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

Project Structure

asteroids-game/
โ”œโ”€โ”€ main.py          # Main game loop and initialization
โ”œโ”€โ”€ constants.py     # Game constants and settings
โ”œโ”€โ”€ requirements.txt # Python dependencies
โ””โ”€โ”€ README.md       # This file

Contributing

Feel free to fork this project and submit pull requests for improvements!

License

This project is open source and available under the MIT License.

About

A classic Asteroids arcade game built with Python and Pygame. Navigate your spaceship through an asteroid field, shooting asteroids while avoiding collisions.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages