A simple physics engine built using C and Raylib to simulate the movement and collision of particles under gravity. The simulation evolves through multiple versions, incorporating friction, variable particle sizes, alpha blending, and interactive playground resizing for enhanced realism.
- ✔️ Basic particle movement under gravity
- ✔️ Elastic collisions between particles
- ✔️ Wall collisions with velocity damping
- ✔️ Friction force to slow particles over time
- ✔️ Variable particle sizes for more realistic dynamics
- ✔️ Alpha blending to simulate fading effects
- ✔️ Interactive playground with resizable boundaries
Ensure you have Raylib installed on your system:
# Download w64devkit from https://github.com/skeeto/w64devkit
# Download raylib from https://github.com/raysan5/raylib/releases
# Extract both and copy raylib files to w64devkit directories
sudo apt install libraylib-dev
brew install raylib
git clone https://github.com/Assem-ElQersh/Particle-Collision-Simulation.git
cd particle-simulation
# Using w64devkit terminal:
gcc "interactive version - resizable playground.c" -o interactive_sim.exe -O2 -Wall -Wno-missing-braces -I raylib/raylib-5.0_win64_mingw-w64/include -L raylib/raylib-5.0_win64_mingw-w64/lib -lraylib -lopengl32 -lgdi32 -lwinmm
./interactive_sim.exe
Version | Features Added |
---|---|
main.c | Basic gravity & collisions |
second version - added friction force.c | Introduced friction for damping |
third version - support particles of different sizes.c | Added variable particle sizes |
fourth version - alpha blending.c | Implemented alpha transparency for fading effect |
interactive version - resizable playground.c | Added interactive playground with draggable boundaries |
- ✔️ Draggable boundaries to resize the playground
- ✔️ Real-time physics adjustment to new boundaries
- ✔️ Visual feedback with yellow boundary lines
- ✔️ Smooth particle transitions when resizing
- ✅ Optimize performance using QuadTree spatial partitioning
- ✅ Implement inelastic collisions for more realism
- ✅ Add particle creation with mouse clicks
- ✅ Use multithreading (OpenMP) to improve efficiency
- ✅ Add save/load playground configurations
This project is licensed under the MIT License. Feel free to use and modify it!