A 2D clicking game built in C++ with Raylib. Click the right balls, avoid the wrong ones, and beat the clock.
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.
- 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 design —
BallandGameclasses encapsulating state, logic, and rendering
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.
- C++ compiler (g++15 recommended)
- Raylib installed
- Make
- pkg-config
make run- Custom
rand<T>()wrapper aroundmt19937for clean random number generation - Collision detection using Raylib's
CheckCollisionCirclesandCheckCollisionPointCircle - Object pooling pattern — 10 pre-allocated
Ballobjects reused across rounds - Three-phase difficulty engine adjusting
showandhiddentimers dynamically
