Skip to content

Pong Multithreaded Linux C++ Game is a modern take on the classic Pong game, utilizing advanced OS concepts. This game features multithreading with separate threads for ball and paddle control, real-time scoring, and engaging graphics using SDL2. Two human players can enjoy competitive gameplay with responsive controls and a seamless experience

Notifications You must be signed in to change notification settings

M-Husnain-Ali/Pong-Multithreaded-Game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽฎ Pong Multithreaded Game - OS Project

Language Platform Library Threading GitHub

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

๐Ÿ“‹ Table of Contents

๐ŸŽฏ Overview

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.

๐Ÿ’ป Requirements

  • 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

๐Ÿš€ Installation & Setup

  1. 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
  2. Install Dependencies

    sudo apt-get update
    sudo apt-get install build-essential
    sudo apt-get install libsdl2-dev libsdl2-ttf-dev
  3. Clone the Repository

    git clone https://github.com/M-Husnain-Ali/Pong-Multithreaded-Game.git
    cd Pong-Multithreaded-Game
  4. Compile the Game

    g++ pong.cpp -o pong -lSDL2 -lSDL2_ttf -pthread
  5. Run the Game

    ./pong

โœจ Features

  • 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

๐ŸŽฎ Game Controls

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

๐Ÿ“œ Game Rules

  1. 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
  2. Gameplay:

    • Ball speed remains constant
    • Paddles move at a fixed speed
    • Ball bounces off paddles and walls
    • Ball resets to center after scoring

๐Ÿ“ Project Structure

pong-multithreaded/
โ”œโ”€โ”€ pong.cpp          # Main game implementation with threading
โ”œโ”€โ”€ README.md         # Project documentation
โ””โ”€โ”€ .git/             # Git repository data

๐Ÿ”ง OS Concepts Demonstrated

  • 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

๐Ÿค Contributing

  1. Fork the repository
  2. Create a new branch
  3. Make your changes
  4. Submit a pull request

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


Made with โค๏ธ by Muhammad Husnain Ali
Operating Systems Course Project

About

Pong Multithreaded Linux C++ Game is a modern take on the classic Pong game, utilizing advanced OS concepts. This game features multithreading with separate threads for ball and paddle control, real-time scoring, and engaging graphics using SDL2. Two human players can enjoy competitive gameplay with responsive controls and a seamless experience

Topics

Resources

Stars

Watchers

Forks

Languages