A classic two-player Pong game implementation using C++ and SFML library.
This is a modern implementation of the classic Pong arcade game where two players control paddles to hit a ball back and forth across the screen. The game features score tracking, high score management, and smooth gameplay mechanics.
- Processor: Any modern processor (Intel Core i3/AMD equivalent or better)
- RAM: 4 GB minimum
- Graphics: Any graphics card supporting OpenGL 2.0
- Storage: 100 MB free space
- Windows 10 or later
- Visual Studio 2022 (Community Edition or higher)
- SFML 2.6.0 or later
- Go to https://www.sfml-dev.org/download.php
- Download SFML 2.6.0 for Visual Studio 2022 (64-bit)
- Extract the downloaded file to a location you can easily find (e.g.,
C:\SFML-2.6.0
)
- Open Visual Studio 2022
- Create a new project or open this project
- Right-click on the project in Solution Explorer
- Select "Properties"
- Make sure "All Configurations" is selected
- Under "C/C++ → General → Additional Include Directories" add:
C:\SFML-2.6.0\include
- Under "Linker → General → Additional Library Directories" add:
C:\SFML-2.6.0\lib
- Under "Linker → Input → Additional Dependencies" add:
sfml-graphics.lib sfml-window.lib sfml-system.lib sfml-audio.lib
- Go to
C:\SFML-2.6.0\bin
- Copy all .dll files
- Paste them into your project's Debug and Release folders (where your .exe is generated)
- Two-player local gameplay
- Real-time score tracking
- High score system with file persistence
- Smooth paddle and ball physics
- Modern graphics using SFML
- Player 1 (Bottom Paddle): Left/Right Arrow Keys
- Player 2 (Top Paddle): A/D Keys
- Exit Game: Escape Key or close window
pong/
│
├── src/ # Source files
│ ├── Pong.cpp # (main.cpp)
│ ├── Paddle.cpp
│ ├── Ball.cpp
│ └── GameStats.cpp
│
├── include/ # Header files
│ ├── Paddle.h
│ ├── Ball.h
│ └── GameStats.h
│
├── assets/ # Game assets
│ ├── fonts/
│ └── screenshots/
│
├── docs/ # Documentation
│ └── documentation.pdf
│
├── .gitignore # Git ignore file
├── README.md # README to check usage
└── Pong.sln # Visual Studio solution file
- Manages paddle position and movement
- Handles paddle collision detection
- Controls paddle speed and direction
- Controls ball movement and physics
- Manages ball collision detection
- Handles speed and direction changes
- Manages scoring system
- Handles high score file I/O
- Tracks game statistics
- Build and run the project in Visual Studio 2022
- Use the controls mentioned above to move the paddles
- Try to hit the ball past your opponent's paddle to score points
- First player to reach the target score wins
- High scores are automatically saved
-
SFML DLL Error:
- Make sure all SFML .dll files are in the same folder as your .exe
- Verify you're using the correct SFML version (2.6.0)
-
Build Errors:
- Double-check SFML include and library paths in project properties
- Ensure you're building for x64 platform
-
Game Not Starting:
- Verify all required files are present
- Check Windows Event Viewer for any error messages
Muhammad Ibrahim Shoeb
BSc in Computer Science Engineering, BME
OZLVV3
- Horton, J. (2019). Beginning C++ Game Programming - Second Edition. Packt Publishing Pvt Ltd.
- Fonts sourced from: www.1001freefonts.com
Feel free to fork the project and submit pull requests for any improvements.