A multithreaded implementation of the classic Pong game, developed as an Operating Systems project to demonstrate practical applications of OS concepts like process management, threading, and synchronization.
Author: Muhammad Husnain Ali
- Overview
- Requirements
- Installation
- Features
- Game Controls
- Game Rules
- Project Structure
- OS Concepts Demonstrated
- Contributing
- License
This project is a modern implementation of the classic Pong game, specifically designed to demonstrate key Operating System concepts. The game utilizes multithreading for smooth performance and responsive controls, showcasing practical applications of process management and thread synchronization in a real-time gaming environment.
- Ubuntu Linux (Tested on Virtual Machine)
- Virtual Machine Software (VirtualBox/VMware recommended)
- C++ Compiler (GCC/G++)
- SDL2 Library and Development Files
- SDL2_ttf Library for Text Rendering
- pthread Library
- Minimum VM Configuration:
- 2GB RAM
- 2 CPU Cores
- 800x600 minimum resolution
- Guest Additions installed for better performance
-
Set Up Ubuntu Virtual Machine
# First ensure your Virtual Machine is properly configured # Install Guest Additions for better performance sudo apt-get update sudo apt-get install virtualbox-guest-utils virtualbox-guest-x11
-
Install Dependencies
sudo apt-get update sudo apt-get install build-essential sudo apt-get install libsdl2-dev libsdl2-ttf-dev
-
Clone the Repository
git clone https://github.com/M-Husnain-Ali/Pong-Multithreaded-Game.git cd Pong-Multithreaded-Game -
Compile the Game
g++ pong.cpp -o pong -lSDL2 -lSDL2_ttf -pthread
-
Run the Game
./pong
- Multithreaded Architecture:
- Separate thread for ball movement
- Independent threads for each paddle
- Smooth gameplay experience
- Demonstrates OS thread management
- Real-time Physics:
- Accurate ball collision detection
- Responsive paddle movement
- Dynamic ball speed
- Score System:
- Real-time score display
- Center-aligned score positioning
- Automatic score updates
- Graphics:
- SDL2 hardware-accelerated rendering
- Clean and minimalist design
- Smooth animations
| Player | Controls | Action |
|---|---|---|
| Player 1 | W |
Move Paddle Up |
| Player 1 | S |
Move Paddle Down |
| Player 2 | โ |
Move Paddle Up |
| Player 2 | โ |
Move Paddle Down |
| Any | ESC |
Quit Game |
-
Scoring:
- Score points when the ball passes opponent's paddle
- Game continues until players decide to quit
- Scores are displayed at the top of the screen
-
Gameplay:
- Ball speed remains constant
- Paddles move at a fixed speed
- Ball bounces off paddles and walls
- Ball resets to center after scoring
pong-multithreaded/
โโโ pong.cpp # Main game implementation with threading
โโโ README.md # Project documentation
โโโ .git/ # Git repository data
-
Process Management:
- Main game process handling
- Resource allocation and management
- Process synchronization
-
Threading Model:
- pthread implementation
- Thread creation and management
- Thread synchronization
- Race condition prevention
- Mutex implementation (implicit in SDL)
-
Memory Management:
- Shared memory between threads
- Resource cleanup and memory deallocation
- Buffer management for rendering
-
I/O Handling:
- Event-driven input processing
- Real-time user input handling
- Graphics buffer management
- Fork the repository
- Create a new branch
- Make your changes
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
Operating Systems Course Project