RayLib Integration
Leverages the high-performance RayLib library for hardware-accelerated 2D rendering.
An interactive, real-time particle simulation built with RayLib that explores gravitational interactions between hundreds of particles in a 2D space.
The Gravity Particle simulation (also known as raylib-particle-toy) models the N-body problem where each particle exerts a gravitational force on every other particle. This leads to the emergence of complex orbital behaviors, clusters, and chaotic trajectories.
RayLib Integration
Leverages the high-performance RayLib library for hardware-accelerated 2D rendering.
C++ Core
Efficient particle physics calculations implemented in modern C++.
N-Body Physics
Calculates gravitational attraction using Newton’s law of universal gravitation.
Cross-Platform
Support for desktop (Windows/Linux) and potential for Android builds.
The simulation tracks each particle’s position, velocity, and mass. At every frame, it calculates the net force acting on each particle:
F = G * (m1 * m2) / r^2particle.h: Defines the particle structure and physics update logic.main.cpp: Manages the simulation loop, RayLib window, and user input.The project uses CMake with presets for a streamlined build process.
Configure CMake
cmake --preset=defaultBuild the Project
cmake --build --preset=defaultRun the Simulation
Execute raylib-particle-toy from the generated build folder.