A 2D space shooter built from scratch in C++ using SDL3.
Created by Tanner Davison
Asteroid Destroyer is my first C++ game project: a multi-player space shooter with physics-based movement, a bullet weapon system, level progression, and a live score display. Built entirely with SDL3, CMake, and vcpkg with no bundled libraries.
Features
- Multi-player V-formation spawn
- Physics-based movement with acceleration, deceleration, and wall bounce
- Fixed timestep game loop (120Hz physics, 120Hz rendering)
- Bullet weapon system with cooldown and collision detection
- Level progression with increasing asteroid counts
- Live score display with SDL3_ttf font rendering
- Cross-platform — macOS, Linux, Windows
| Tool | Version |
|---|---|
| CMake | 3.15+ |
| vcpkg | latest |
| GCC / Clang / MSVC | C++23 support |
Before cloning, make sure your system has a C++23 compiler and CMake installed.
macOS
xcode-select --install
brew install cmakeLinux
sudo apt install build-essential cmake gitWindows
Install Visual Studio 2022 with the Desktop development with C++ workload. This includes MSVC, CMake, and the Windows SDK.
git clone https://github.com/microsoft/vcpkg.git ~/vcpkg
cd ~/vcpkg
./bootstrap-vcpkg.sh # macOS / Linux
.\bootstrap-vcpkg.bat # WindowsAdd to your shell profile (~/.zshrc, ~/.bashrc, or PowerShell $PROFILE):
export VCPKG_ROOT=~/vcpkg
export CMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmakeSDL3, SDL3_image, and SDL3_ttf are installed automatically by vcpkg on first configure.
git clone https://github.com/Tanner-Davison/asteroid-destroyer-sdl.git
cd asteroid-destroyer-sdl
mkdir build && cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake
make -j$(sysctl -n hw.logicalcpu) # macOS
make -j$(nproc) # Linuxgit clone https://github.com/Tanner-Davison/asteroid-destroyer-sdl.git
cd asteroid-destroyer-sdl
mkdir build && cd build
cmake .. -G "Visual Studio 17 2022" -A x64
cmake --build . --config Release./build/asteroid-destroyer # macOS / Linux
.\build\asteroid-destroyer.exe # Windows| Key | Action |
|---|---|
| W / ↑ | Move up |
| S / ↓ | Move down |
| A / ← | Move left |
| D / → | Move right |
| Space | Shoot |
| Left Shift | Boost |
asteroid-destroyer/
├── src/
│ ├── main.cpp # Game loop and collision orchestration
│ ├── Player.cpp/hpp # Movement, input, texture, collision
│ ├── weapon.cpp/hpp # Bullet pool and shoot cooldown
│ ├── asteroid.cpp/hpp # Spawn, physics, wrap-around
│ ├── score.cpp/hpp # Score state and TTF rendering
│ └── createwindow.cpp/hpp # SDL3 init, window, renderer
├── assets/fonts/ # FiraCode font
├── CMakeLists.txt
└── vcpkg.json
MIT