Skip to content

Latest commit

 

History

39 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Galaga (SDL2) — Simple C++ remake

A compact Galaga-like arcade shooter implemented in C++ using SDL2 and CMake.

Download

Download page --> https://heqon.github.io/galaga-sdl2/

Screenshots

Galaga Gameplay1 Galaga Gameplay2 Galaga Menu Galaga Leaderboard

Features

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

Overview

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

Repository layout

  • assets — textures, sounds, fonts and data/leaderboard.txt
  • include — public headers
  • src — sources and main.cpp
  • build — generated build files (ignored by git normally)

Requirements

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-dev

Windows

Two common options:

  • Visual Studio + vcpkg (recommended)
  • MSYS2 / MinGW

Using vcpkg (recommended):

  1. Install vcpkg: https://github.com/microsoft/vcpkg
  2. Install SDL packages:
vcpkg install sdl2 sdl2-image sdl2-mixer sdl2-ttf

When 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 Release

Using MSYS2 (MinGW): install the toolchain and SDL packages with pacman, then build from an MSYS2 MinGW shell.

Build Instructions

Linux (out-of-source build):

mkdir -p build
cd build
cmake ..
cmake --build . -- -j$(nproc)
# or: make -j$(nproc)
./galaga

Windows (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.exe

Windows (MinGW / MSYS2):

# from MSYS2 MinGW64 shell
mkdir -p build
cmake -G "MinGW Makefiles" -S . -B build
cmake --build build --config Release
./build/galaga.exe

Notes

  • If CMake cannot find SDL2, either install the development packages (Linux) or point CMake to SDL2 via -DCMAKE_PREFIX_PATH or the vcpkg toolchain file.
  • For manual SDL2 installs on Windows, set SDL2_DIR or use CMAKE_PREFIX_PATH to the folder containing SDL2Config.cmake.

Running the Game

  • Run the built binary (./galaga on Linux, galaga.exe on 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.

Gameplay

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

Controls

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

Assets

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

Troubleshooting

  • "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.

Development notes

  • The project uses CMake; to add libraries or change flags, edit CMakeLists.txt in the repository root.
  • Headers are in include/, sources are under src/source/.

License

This project includes an existing LICENSE file. Check it for licensing terms.

Contact / Contributions

Contributions and fixes are welcome. Open issues or submit pull requests with concise descriptions and tests where applicable.

About

A retro 2D Galaga clone in C++11 & SDL2 featuring dynamic enemy formations, tactical dives, wave scaling, epic boss encounters, and power-up drops.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages