Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Pong Game is a simple engaging game built with Raylib, where players control a paddle to keep a bouncing ball in play. The game features dynamic ball physics, a scoring system, and a limited number of lives. Players move the paddle using arrow keys to prevent the ball from falling off the screen.

Notifications You must be signed in to change notification settings

skhalifa05/RayLib-Pong

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Raylib Pong Game 🎮

A simple pong game built using C++ and Raylib. The game features a paddle controlled by the player, a bouncing ball, and a lives system. The goal is to keep the ball from falling off the screen while increasing your score. ss.png

Game Concept

Paddle Bounce challenges players to control a paddle at the bottom of the screen, bouncing a ball to keep it in play. The goal is to maintain control, avoid missing the ball, and rack up points by bouncing it off the paddle. Players have a limited number of lives, and the game ends when all lives are lost.

Gameplay

  • Use the left (←) and right (→) arrow keys to move the paddle.
  • The ball bounces off the paddle and walls, but if it falls below the screen, you lose a life.
  • The game tracks your score and lives, displaying them in real time.
  • The ball changes color when it bounces off the paddle.
  • The game ends when you run out of lives.

Features

  • Paddle Control: Move left and right to hit the ball.
  • Dynamic Ball Physics: Ball bounces off walls, ceiling, and paddle.
  • Score System: Gain points for successful paddle hits.
  • Life System: Lose a life when the ball touches the bottom.
  • Color Switching: Paddle hits change the background color.
  • Screen Wrapping: Paddle re-enters from the opposite side if it moves beyond the screen boundaries.
  • Power-Up System: Collect power-ups that spawn randomly to enhance gameplay. Power-ups can provide effects such as:
    • Larger Paddle: increases the paddle’s width for easier ball control.
    • Extra Life: Grants an additional life to extend gameplay.

Code Structure

The game follows an object-oriented design and includes the following classes:

Class Responsibility
GameManager Controls game logic, updates, and rendering (Singleton Pattern).
Ball Handles movement, bouncing, and resets.
Paddle Controls user input and movement.
LivesManager Tracks player lives and updates the UI.
PowerUpManager Spawns, tracks, and executes power-ups.
PowerUp Base class for all power-ups, defining common behavior.
LargerPaddle Inherits from PowerUp, increases paddle size when activated.
ExtraLife Inherits from PowerUp, grants an additional life.

📂 Project Structure

📦 PaddleBounce
├── include/
├── lib/
├── src/
│   ├── PowerUps/
│   │   ├── ExtraLife.h        # Header for Extra Life
│   │   ├── ExtraLife.cpp        # PowerUp for Larger Paddle Powerup
│   │   ├── LargePaddle.h        # Header for Larger Paddle Powerup
│   │   ├── LargePaddle.cpp        # PowerUp for Larger Paddle Powerup
│   │   └── PowerUp.h        # Powerup Interface
│   ├── main.cpp        # Game loop and initialization
│   ├── GameManager.cpp # Singleton managing game logic
│   ├── Ball.cpp        # Ball physics and movement
│   ├── Paddle.cpp      # Paddle control
│   ├── LivesManager.cpp # Lives tracking
│   ├── GameManager.h   # Header for GameManager
│   ├── Ball.h          # Header for Ball class
│   ├── Paddle.h        # Header for Paddle class
│   ├── LivesManager.h  # Header for LivesManager class
├── README.md           # Project documentation
└── Makefile            # Build instructions

Prerequisites

Possible Improvements 🚀

  • Add difficulty levels (ball speed increases over time).
  • Implement a pause menu and restart option.
  • Add sound effects for collisions.
  • Introduce power-ups (e.g., bigger paddle, slow-motion).

License

This project is open-source under the MIT License.

About

Pong Game is a simple engaging game built with Raylib, where players control a paddle to keep a bouncing ball in play. The game features dynamic ball physics, a scoring system, and a limited number of lives. Players move the paddle using arrow keys to prevent the ball from falling off the screen.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published