Space Shooter 1045 is a classic arcade-style shooter game built in C++ with the SplashKit library. Inspired by retro games like Space Invaders and Galaga. Control your spaceship, dodge asteroids, and destroy enemies to get the high score!
- Main Menu & Game States: A complete game flow with a main menu, leaderboard screen, and a game-over screen.
- Player Controls: Full control to move the ship with the arrow keys, rotate (
A/D), and fire projectiles (Spacebar). - Dynamic HUD: An in-game HUD shows the current score, remaining lives, and active power-ups with icons.
- Multiple Enemy Types:
- Standard Enemies: Move to a point and fire bullets.
- Homing Enemies: Track and follow the player's movements.
- Rotating Enemies: Fire bullets in a circular pattern.
- Obstacles: Asteroids fly across the screen, posing a threat to the player.
- Power-Up System:
- Extra Life: Instantly grants the player an additional life.
- Shield: A temporary shield that protects the player from damage.
- Multi-Shot: A temporary boost that allows the player to fire multiple bullets at once.
- Persistent Leaderboard: Top 10 scores are saved to and loaded from a local
leaderboard.jsonfile, persisting between game sessions. - Audio: Immersive background music and sound effects for shooting, explosions, and power-ups.
- Visuals & Animations:
- Pixel-art graphics and fonts.
- Explosion animations when enemies and rocks are destroyed.
- Increasing Difficulty: The game becomes more challenging as your score increases, spawning more enemies that move and shoot faster.
- Language: C++
- Core Library: SplashKit SDK (used for graphics, audio, input handling, JSON, and animations)
- External Library: stduuid (a header-only library used for generating unique IDs for game object timers)
Follow these instructions to compile and run the project on your local machine.
- SplashKit: You must have the SplashKit SDK installed and configured for your environment.
stduuidLibrary: This project requires theuuid.hheader file.- Download the header file from the repository: https://github.com/mariusbancila/stduuid
- Place the
uuid.hfile inside theinclude/folder in the project's root directory.
- Resources: Ensure the
resources/folder (containing all images, sounds, fonts, and JSON files) is in the same directory as the final executable. - Compile: Open your terminal, navigate to the project's root directory, and run the following command:
clang++ -std=c++20 src/*.cpp -o spaceshooter -I./include -I SplashKit -framework CoreFoundation - Run: Once compiled, run the executable[cite: 510]:
./spaceshooter
- Move: Arrow Keys
- Rotate:
A(Counter-Clockwise) &D(Clockwise) - Shoot:
Spacebar - Start Game:
Spacebar(from Main Menu) - View Leaderboard:
L(from Main Menu) - Return to Menu:
Spacebar(from Game Over / Leaderboard screen)
The project is built using an Object-Oriented (OOP) design, with responsibilities split into logical classes:
Game: The main controller class, managing the game loop, states (GameState), and all entity collections.Entity(Abstract): A base class for all on-screen objects (Player, Enemy, Rock, etc.), defining shared properties like position, sprite, and active state.Shooter(Abstract): An abstract class encapsulating firing logic, inherited byPlayerandEnemy.Player: Manages player input, state (lives, score), and active power-ups.Enemy(Hierarchy): A baseEnemyclass with specialized subclasses likeHomingEnemyandRotatingEnemy.PowerUp(Hierarchy): A basePowerUpclass with subclasses for each power-up type (ShieldPowerUp,MultiShotPowerUp, etc.).- Factories:
EnemyFactoryandPowerUpFactoryare used to create and spawn new game objects, decoupling theGameclass from specific entity types. Leaderboard: Handles loading from and saving scores to theleaderboard.jsonfile.
This modular architecture makes the codebase clean, maintainable, and easy to extend.
All assets used in this project are from open-source repositories and credited to their creators.
- Player Bullet: pngegg.com
- Spaceship, Enemies: OpenGameArt.org
- Asteroid/Rock: OpenGameArt.org
- Enemy Bullet: Pixilart.com
- Background: norma_2d (X/Twitter), Alpha Coders
- Astronaut (Unused): gogoat1 (DeviantArt)
- Explosion Animation: OpenGameArt.org
- Life Power-up: CityPNG.com
- Shield Power-up: pngtree.com
- Shielded Player Effect: pngtree.com
- Pixel Font: cooltext.com
- Explosion Sound: Sound Effect by Lumora Studios from Pixabay
- Enemy Shoot Sound: Sound Effect by freesound_community from Pixabay
- Player Shoot Sound: Sound Effect by Jurij from Pixabay
- Game Over Sound: Sound Effect by freesound_community from Pixabay
- Background Music: Music by Serhii Kliets from Pixabay
- Power-up Sound: Sound Effect by freesound_community from Pixabay
This project is licensed under the MIT License.