A classic single-player Pong game built with C++17 and SFML 2.5.
- Smooth bat movement with bounded clamping
- Randomised ball direction on each new life
- Score tracking (incremented on top-wall bounces)
- Lives system with Game Over screen
- Press R to restart without relaunching
| Key | Action |
|---|---|
| ← / → Arrow | Move bat |
| R | Restart after game over |
| Esc | Quit |
| Tool | Version |
|---|---|
| C++ compiler | GCC 9+ / Clang 10+ / MSVC 2019+ |
| CMake | 3.16+ |
| SFML | 2.5.x |
Ubuntu / Debian
sudo apt install libsfml-devmacOS (Homebrew)
brew install sfmlWindows
Download the pre-built binaries from sfml-dev.org and set SFML_DIR in CMake.
git clone https://github.com/AKumarOfficial/pong.git
cd pong
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build buildThe binary is placed in build/ alongside the font/ folder.
./build/Pong # Linux / macOS
build\Pong.exe # Windowspong/
├── include/
│ ├── Ball.h # Ball declarations
│ ├── Bat.h # Bat declarations
│ ├── Constants.h # All tunable game constants
│ └── GameState.h # GameState enum
├── src/
│ ├── Ball.cpp
│ ├── Bat.cpp
│ └── main.cpp # Game loop & entry point
├── font/
│ └── KOMIKAP_.ttf
├── CMakeLists.txt
├── .gitignore
└── README.md
All gameplay constants (window size, speeds, ball radius, lives, etc.) live in include/Constants.h. Adjust them there without touching game logic.
MIT — see LICENSE for details.