Skip to content

BehnamMozafari/SpaceShooter1045

Repository files navigation

Space Shooter 1045

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!

Features

  • 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.json file, 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.

Tech Stack

  • 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)

Getting Started

Follow these instructions to compile and run the project on your local machine.

Prerequisites

  1. SplashKit: You must have the SplashKit SDK installed and configured for your environment.
  2. stduuid Library: This project requires the uuid.h header file.

Installation & Running

  1. Resources: Ensure the resources/ folder (containing all images, sounds, fonts, and JSON files) is in the same directory as the final executable.
  2. 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
  3. Run: Once compiled, run the executable[cite: 510]:
    ./spaceshooter

Controls

  • 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)

Project Structure

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 by Player and Enemy.
  • Player: Manages player input, state (lives, score), and active power-ups.
  • Enemy (Hierarchy): A base Enemy class with specialized subclasses like HomingEnemy and RotatingEnemy.
  • PowerUp (Hierarchy): A base PowerUp class with subclasses for each power-up type (ShieldPowerUp, MultiShotPowerUp, etc.).
  • Factories: EnemyFactory and PowerUpFactory are used to create and spawn new game objects, decoupling the Game class from specific entity types.
  • Leaderboard: Handles loading from and saving scores to the leaderboard.json file.

This modular architecture makes the codebase clean, maintainable, and easy to extend.

Asset Sources & Attributions

All assets used in this project are from open-source repositories and credited to their creators.

Graphics

Fonts

Audio

License

This project is licensed under the MIT License.

About

A classic arcade-style shooter game built in C++

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages