A compact Galaga-like arcade shooter implemented in C++ using SDL2 and CMake.
Download page --> https://heqon.github.io/galaga-sdl2/
- Classic Arcade Wave System: Progressively harder stages with increasing enemy counts, dynamic spawn rates, and difficulty scaling.
- Epic Boss Waves: Every 3rd wave triggers a unique Boss encounter. The Boss features scaled sizing, increased durability (multi-hit health pool), and faster, more aggressive attack rates.
- Strategic Enemy AI & Behaviors:
- Entering State: Enemies dynamically swoop into the screen to form up.
- Formation Movement: Organized fleet behavior featuring smooth, synchronized sine-wave horizontal sways.
- Diving Maneuvers: Randomly triggered individual diving attacks where enemies break formation to swoop down on the player.
- Returning Loops: Seamlessly re-entering the formation from the top if a diving run completes without hitting the player.
- Power-Up System: Collect dynamic drops during gameplay to turn the tide:
- Rapid Fire: Maximizes your attack rate by significantly decreasing your firing delay.
- Triple Shot: Spreads your firepower across three streams to clear the screen faster.
- Shield: Grants temporary invulnerability against enemy collisions and lasers.
- Health Restore: Repairs your ship to keep you in the fight longer.
- Persistent Leaderboard: Saves and tracks high scores locally via an automated text file registry (
leaderboard.txt). - Retro Audio & Visuals: Powered by SDL2_mixer and SDL2_image, providing vintage space ambient music, arcade laser sound effects, and explosive visual feedbacks.
- Project: A small 2D space shooter using SDL2 for rendering, input and audio.
- Language: C++ (C++11+)
- Build system: CMake
- Assets: Stored in the assets directory (textures, sound, font, data).
This README describes how to build and run the project on Linux and Windows, required dependencies, and common troubleshooting tips.
- assets — textures, sounds, fonts and
data/leaderboard.txt - include — public headers
- src — sources and
main.cpp - build — generated build files (ignored by git normally)
Common prerequisites
- CMake (3.10+ recommended)
- A C++ compiler supporting C++11 or newer
- SDL2 and related development packages: SDL2, SDL2_image, SDL2_mixer, SDL2_ttf
Linux (Debian/Ubuntu example)
Install dependencies:
sudo apt update
sudo apt install -y build-essential cmake pkg-config \
libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-devWindows
Two common options:
- Visual Studio + vcpkg (recommended)
- MSYS2 / MinGW
Using vcpkg (recommended):
- Install vcpkg: https://github.com/microsoft/vcpkg
- Install SDL packages:
vcpkg install sdl2 sdl2-image sdl2-mixer sdl2-ttfWhen configuring with CMake, pass the vcpkg toolchain file:
cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=C:/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake -G "Visual Studio 17 2022"
cmake --build build --config ReleaseUsing MSYS2 (MinGW): install the toolchain and SDL packages with pacman, then build from an MSYS2 MinGW shell.
Linux (out-of-source build):
mkdir -p build
cd build
cmake ..
cmake --build . -- -j$(nproc)
# or: make -j$(nproc)
./galagaWindows (Visual Studio + vcpkg):
cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=C:/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake -G "Visual Studio 17 2022"
cmake --build build --config Release
.\build\Release\galaga.exeWindows (MinGW / MSYS2):
# from MSYS2 MinGW64 shell
mkdir -p build
cmake -G "MinGW Makefiles" -S . -B build
cmake --build build --config Release
./build/galaga.exeNotes
- If CMake cannot find SDL2, either install the development packages (Linux) or point CMake to SDL2 via
-DCMAKE_PREFIX_PATHor the vcpkg toolchain file. - For manual SDL2 installs on Windows, set
SDL2_DIRor useCMAKE_PREFIX_PATHto the folder containingSDL2Config.cmake.
- Run the built binary (
./galagaon Linux,galaga.exeon Windows). - The
assets/directory must be located relative to the executable as in the repository — do not move assets unless you update paths in the code. - Leaderboard is stored in assets/data/leaderboard.txt.
- Objective: Survive infinite waves of alien invaders, defeat the heavy Boss every 3rd wave, and secure the highest score on the leaderboard.
- Health System: The player starts with multiple health points. Getting hit by an enemy laser or crashing into a diving enemy reduces health.
- Power-Ups: Hitting certain enemies drops special tokens. Move your ship over them to instantly activate buffs like Triple Shot or Shield.
- W/A/S/D: Move player
- Space: Fire
- F11: Fulscreen/Windowed
- Esc: Quit
If your keyboard layout differs, controls can be remapped by editing the source (search for input handling in src/).
- Images:
assets/texture/ - Sounds:
assets/sound/ - Font(s):
assets/font/ - Leaderboard data:
assets/data/leaderboard.txt
Do not remove or rename files in the assets/ tree unless you change the code paths accordingly.
- "SDL2 not found" during CMake: ensure dev packages are installed or pass
-DCMAKE_PREFIX_PATH/vcpkg toolchain. - Runtime errors about missing files: confirm the
assets/directory is next to the executable or run from the repository root. - Linker errors on Windows: verify you built with the same runtime (MSVC vs MinGW) and that SDL libraries match the toolchain.
- The project uses CMake; to add libraries or change flags, edit
CMakeLists.txtin the repository root. - Headers are in
include/, sources are undersrc/source/.
This project includes an existing LICENSE file. Check it for licensing terms.
Contributions and fixes are welcome. Open issues or submit pull requests with concise descriptions and tests where applicable.



