A classic Pong game built with C++ and Raylib, developed as a hands-on project to learn the C++ language from scratch.
This project was initially built by following the tutorial below, then expanded with my own modifications and improvements:
| Input | Action |
|---|---|
| ↑ Arrow / D-Pad Up | Move paddle up |
| ↓ Arrow / D-Pad Down | Move paddle down |
Clone the repository recursively to pull raylib and SDL2 from submodules:
git clone --recursive --depth=1 https://github.com/GuilhermeAQN/PongRaylibCPP.git
cd PongRaylibCPPAlready cloned without
--recursive? Run:git submodule update --init --recursive
| Tool | Purpose | Required? |
|---|---|---|
g++ (MinGW or w64devkit) |
C++ compiler | ✅ Yes |
mingw32-make |
Build system | ✅ Yes (comes with w64devkit) |
Don't have these?
- Download w64devkit — extract anywhere and add
w64devkit/binto your PATH. - Or use any MinGW distribution (MSYS2, TDM-GCC, etc.) — as long as
g++andmingw32-makework in your terminal.
Note: All libraries (compiled Raylib and SDL2) are already included in
third_party/. You do not need to install or compile them separately — unless you want to rebuild Raylib for a different platform.
make
.\game.exe| Variable | Default | Description |
|---|---|---|
COMPILER_PATH |
C:/raylib/w64devkit/bin |
Path to g++ and tools (?=, can be overridden) |
RAYLIB_PATH |
third_party/raylib |
Path to raylib source and libs |
PLATFORM |
PLATFORM_DESKTOP |
Target platform |
BUILD_MODE |
RELEASE |
DEBUG or RELEASE |
Override example:
make COMPILER_PATH=C:/my/path/w64devkit/bin
make BUILD_MODE=DEBUGTargets:
| Command | What it does |
|---|---|
make |
Build desktop |
make clean |
Remove compiled files |
make web |
Build for web (requires Emscripten SDK) |
⚠️ Requires the Emscripten SDK configured on your machine. Skip this section if you don't have it.
make webThen open the result in a browser:
# Serve locally
python -m http.server 8000 --directory build/webOr open build/web/index.html directly in your browser.
- Language: C++ 14
- IDE: VS Code with C/C++ extension
- Graphics Library: Raylib v5.5 (compiled with SDL2)
- Key C++ concepts applied:
- Nested structs and encapsulation
- Struct inheritance (
CpuPaddleextendsPaddle) - References and const correctness
- Variables, functions and scope
- Conditionals and game loop
- Gamepad input with SDL2 vibration
PongRaylibCPP/
├── src/
│ └── main.cpp # Full game source code
├── third_party/
│ ├── SDL2 # Gamepad input and vibration support
│ └── raylib # Graphics rendering and window management
├── Makefile # Build configuration
└── README.md
This project was built to learn C++ through practical game development. Raylib was chosen for its simplicity, allowing me to focus on C++ fundamentals rather than low-level graphics boilerplate.
Developed by Guilherme Nogueira
