Skip to content

kasyapArchit/asteroid

Repository files navigation

Asteroid Game

A classic arcade-style asteroid game built with Python and Pygame. Navigate your ship, shoot asteroids, and survive as long as you can!

Features

  • Ship Control: Rotate and move your triangle-shaped spaceship
  • Shooting: Fire bullets to destroy asteroids
  • Asteroid Splitting: Larger asteroids break into smaller pieces when destroyed
  • Collision Detection: Game ends when your ship collides with an asteroid
  • Game Logging: Events and game state are logged for tracking gameplay

Requirements

  • Python 3.13+
  • pygame 2.6.1

Installation

  1. Clone or download this repository
  2. Ensure you have Python 3.13 or higher installed
  3. Install dependencies:
pip install -r requirements.txt

Or using uv:

uv sync

How to Play

Run the game with:

python main.py

Controls

Key Action
W Move forward
S Move backward
A Rotate left
D Rotate right
SPACE Shoot

Objective

  • Destroy all asteroids by shooting them
  • Avoid colliding with asteroids
  • Each asteroid destroyed by shooting splits into two smaller asteroids
  • The game ends when your ship collides with an asteroid

Game Mechanics

  • Asteroids: Appear randomly on the screen and move in various directions
  • Splitting: When shot, asteroids split into smaller pieces (except for the smallest size)
  • Shooting Cooldown: You can only shoot one bullet at a time with a brief cooldown between shots
  • Screen Wrapping: Objects that move off-screen wrap around to the opposite side

Project Structure

  • main.py - Main game loop and event handling
  • player.py - Player ship class with movement and shooting logic
  • asteroid.py - Asteroid class with collision and splitting behavior
  • asteroidfield.py - Spawns and manages asteroids
  • shot.py - Bullet/shot class
  • circleshape.py - Base class for circular entities
  • constants.py - Game constants and configuration
  • logger.py - Event and state logging system

Dependencies

See pyproject.toml for the complete list of dependencies.

About

Game to play asteroid shooting

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages