Skip to content

Latest commit

 

History

147 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Asteroid Destroyer

A 2D space shooter built from scratch in C++ using SDL3.

Created by Tanner Davison


About

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

Prerequisites

Tool Version
CMake 3.15+
vcpkg latest
GCC / Clang / MSVC C++23 support

Environment Setup

Before cloning, make sure your system has a C++23 compiler and CMake installed.

macOS

xcode-select --install
brew install cmake

Linux

sudo apt install build-essential cmake git

Windows

Install Visual Studio 2022 with the Desktop development with C++ workload. This includes MSVC, CMake, and the Windows SDK.


Install vcpkg

git clone https://github.com/microsoft/vcpkg.git ~/vcpkg
cd ~/vcpkg
./bootstrap-vcpkg.sh   # macOS / Linux
.\bootstrap-vcpkg.bat  # Windows

Add to your shell profile (~/.zshrc, ~/.bashrc, or PowerShell $PROFILE):

export VCPKG_ROOT=~/vcpkg
export CMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake

Building

SDL3, SDL3_image, and SDL3_ttf are installed automatically by vcpkg on first configure.

macOS / Linux

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)                     # Linux

Windows

git 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

Running

./build/asteroid-destroyer      # macOS / Linux
.\build\asteroid-destroyer.exe  # Windows

Controls

Key Action
W / ↑ Move up
S / ↓ Move down
A / ← Move left
D / → Move right
Space Shoot
Left Shift Boost

Project Structure

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

License

MIT

About

Asteroid Destroyer multi platform SDL3 game

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages