Skip to content

labib0x9/Bounce

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bounce

A 2D clicking game built in C++ with Raylib. Click the right balls, avoid the wrong ones, and beat the clock.

gameplay


Gameplay

You have 30 seconds. Colored balls appear and disappear on screen:

Ball Color Effect
🟢 Green +1 point
🟡 Gold +2 points
🔴 Red -1 point

Click as many green and gold balls as you can. Avoid red ones. The game gets harder over time — balls flash faster as the clock runs down.

Controls: Mouse click only. Press R to restart after game over.


Features

  • Game state machine — clean transitions between START, PLAYING, and GAME OVER screens
  • Dynamic difficulty — three phases that progressively shorten ball visibility duration
  • Random spawning with overlap prevention — balls reposition without clipping into each other
  • Frame-rate independent timing — smooth behavior at any FPS using GetFrameTime()
  • Score feedback — point value displayed on click at ball position
  • OOP designBall and Game classes encapsulating state, logic, and rendering

Architecture

main.cpp        — game loop, input handling, state transitions
assets          - store max score

├── assets
│   ├── gameplay.gif
│   └── max_score.txt
├── bounce
├── main.cpp
├── main.o
├── Makefile
├── README.md
└── src
    ├── ball.cpp
    ├── ball.h
    ├── ball.o
    ├── game.cpp
    ├── game.h
    └── game.o

Ball class manages position, radius, color, score value, active state, and drawing.

Game class owns the ball pool, score, elapsed time, game state, and difficulty phase logic.


Building

Requirements

  • C++ compiler (g++15 recommended)
  • Raylib installed
  • Make
  • pkg-config

Linux / macOS

make run

Technical Highlights

  • Custom rand<T>() wrapper around mt19937 for clean random number generation
  • Collision detection using Raylib's CheckCollisionCircles and CheckCollisionPointCircle
  • Object pooling pattern — 10 pre-allocated Ball objects reused across rounds
  • Three-phase difficulty engine adjusting show and hidden timers dynamically

About

2D clicking game using raylib and cpp

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors