Skip to content

Latest commit

 

History

History
125 lines (87 loc) · 3.16 KB

File metadata and controls

125 lines (87 loc) · 3.16 KB

Raylib Particle Fireworks

C++ raylib platform

A real-time fireworks simulator written in modern C++ with Raylib. Built from scratch to showcase clean OOP design, mathematically-driven visuals, and robust engineering practices valued by professionals and recruiters.


Features

Architecture:

  • Class-based (Particle) encapsulating physics, rendering, and life-cycle
  • Self-contained update/render loop with delta-time integration
  • Efficient memory management (particles and trails)

Visuals:

  • Radial explosions, spirals, and fountains
  • Particle trails with alpha fading
  • Dynamic color transitions (base → red → transparent)
  • Size scaling over lifetime

Math & Physics:

  • Gravity and velocity updates each frame
  • Trigonometric angle→vector conversion
  • Linear interpolation for color and size

Performance:

  • Trail length limit
  • Backwards vector erasure for removal
  • No heap allocation inside the frame loop

Controls:

  • Left Click: Radial explosion at mouse
  • F key: Fountain effect
  • S key: Spiral pattern

Project Structure

fireworks/
├─ src/
│  ├─ main.cpp          # entry point and game loop
└─ README.md

Build & Run

Step 1: Install Raylib

# Debian / Ubuntu
sudo apt install libraylib-dev

# macOS (Homebrew)
brew install raylib

# Windows (MSYS2)
pacman -S mingw-w64-x86_64-raylib

Step 2: Compile

# Linux / macOS
g++ -std=c++11 src/*.cpp -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -o fireworks

# Windows (MinGW)
g++ -std=c++11 src/*.cpp -lraylib -lopengl32 -lgdi32 -lwinmm -o fireworks.exe

Or, with CMake:

mkdir build && cd build
cmake ..
cmake --build .

Step 3: Run

./fireworks

Code Highlights

Step Concept Example Code/Logic
1. Particle Class constructor sets position, velocity, life, baseColor
2. Physics Update velocity.y += GRAVITY * dt; position += velocity * dt;
3. Trail Capture push current position, trim to MAX_TRAIL_LENGTH
4. Patterns Explosion, spiral, fountain use trig for vectors

Why This Project Matters

  • Game-ready techniques: Demonstrates core game engine and graphics concepts
  • Math competence: Shows trigonometry, interpolation, and delta-time animation
  • Clean engineering: Readable, modular, and efficient (SOLID-inspired)
  • Recruiter appeal: Focus on modern C++ design, graphics, real-time logic, and code quality

Roadmap

  • Sound effects (explosion crackle, launch whistle)
  • Configurable JSON-based firework presets
  • GPU sprite-based particles (performance boost)
  • 3D camera & depth-sorted particles

Contributing

Pull requests are welcome—especially for new explosion patterns, performance tips, or bug fixes. Feel free to open issues for suggestions!