2D N-Body Simulation in C++ (v2) @s0lly
2D N-Body Simulation in C++ (v2)  @s0lly
Uploaded April 2019 | Updated September 2026, 33 minutes ago
This engine allows the user to input thousands of objects and watch an n-body physics display occur. If objects collide, those objects will "merge".

The number at the top left represents the number of objects remaining in the simulation.

The camera "locks-on" to the largest mass object and follows it around, moving to any larger object as objects merge.

It relies on only a few functions and objects to do all the work, so hopefully the code is quite easy to understand and follow.

The codebase can be found here: github.com/s0lly/NBody-Physics

Please let me know how I could improve this!

This was made using the Chili Framework: http://wiki.planetchili.net/index.php... - thanks Chili!
2D N-Body Simulation in C++ (v2)AI Steering Behaviour Visualisation v6: Steering ForcesImage Editor - Update 2: Layers and LightLocking Positons & Orientations on Rotating ObjectsAI Steering Behaviour Visualisation v5: PredatorMaze Visualizations: 4) Shapes and WordsPixCells 4: Files & MenusGame Engine 13: Simple AtmosphereTransparent Windows feat. Bevy [Rust]Project Overlay 03: Text BoxesCountdown To NYE - A Simple Button Masher in C++Shadow Casting - in Excel!?!
s0lly |

2D N-Body Simulation in C++ (v2)

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER