Welcome to The Space War, an exciting and fast-paced game where you control a spaceship to defeat enemy ships and avoid their bullets. Created using Pygame, this game features vibrant graphics, smooth controls, and thrilling gameplay.
I created The Space War as a fun project to experiment with game development. Although my main focus is AI development, I wanted to try something new and explore the world of game creation. This project was a way to challenge myself by combining skills in game mechanics, animation, and user interaction. It was a refreshing break from AI development, allowing me to learn and experiment in a new domain!
-
Player Ship Controls:
- Use the arrow keys or A/D keys (left/right) to move the ship.
- Alternatively, move the ship with your mouse by pointing to the desired location.
- Press Spacebar or click the left mouse button to shoot.
-
Objective:
- Destroy enemy ships while avoiding their bullets.
- Score points for each enemy ship destroyed.
- The game ends when you get hit by an enemy bullet.
- Player Ship: A moveable ship controlled by either keyboard or mouse.
- Enemies: Enemy ships spawn at random positions and move downwards.
- Bullets: Both the player and enemy ships shoot bullets.
- Explosions: Visual effects show explosions when an enemy is destroyed or when the player gets hit.
- Score System: Track your score as you destroy enemy ships.
- Pygame: The primary library used to develop the game, handling graphics, events, and sound.
- Python: The programming language used for its simplicity and flexibility.
- Pygame.mixer: Manages game sounds and audio effects, such as shooting and explosions.
The game uses custom images and sounds stored locally. To ensure proper operation, make sure all the following assets are in the specified directories:
- Background Image: The background for the game screen.
- Player Ship Image: Represents the player's spaceship.
- Enemy Ship Image: Represents the enemy ships.
- Bullet Images: Represents the player’s and enemy’s bullets.
- Explosion Image: Used for explosion animations.
- Game Over Image: Displayed when the game ends.
- Laser Sound: Played when the player fires a bullet.
- Explosion Sound: Played when an enemy is destroyed or the player is hit.
Ensure you have Python 3 and Pygame installed. You can install Pygame with the following command:
pip install pygame
Clone the repository to your local machine:
git clone https://github.com/Sd338/The-Space-War.git
Make sure to place all the necessary image and sound asset files in the correct directories as indicated in the code.
- After setting up the assets and dependencies, open a terminal/command prompt.
- Navigate to the project directory.
- Run the game using the following command:
python main.py
The game window will appear, and you can start playing right away.
- If you encounter errors related to missing assets, double-check that the image and sound file paths are correct.
- If the game is lagging, try reducing the number of enemies or adjusting the resolution.
If you'd like to contribute to this project, feel free to fork the repository, make changes, and submit a pull request. Your contributions are always welcome!
This is an open-source project. You are free to use, modify, and distribute it, but please credit the original author.