Gravity simulation is a user-friendly program which allows the user to experiment with the force of gravity and get a visual demonstration of it. In most cases (if time per update is low enough) the simulation is very accurate. It runs Newton's law of universal gravitation many times per second, so it is able to quickly simulate complex systems with up to 1000 objects. The objects would act almost like they would in real life.
The executable file requires the Resources folder and files msvcp140.dll, msvcp140_1.dll, vcruntime140.dll and vcruntime140_1.dll to run (all of them are located here). All the source files can be found here.
- Esc - switch menu
- Dragging while holding left click - move around the map
- Left click on an object - select the object
- Zoom in/out (mouse scroll) - change scale
- Right click - delete all the objects near the cursor
- P - pause
- < - slow down the time speed
- > - speed up the time speed
- T / / - access the command line
- F11 - switch to fullscreen mode
- All the other controls are available in the menu
First, select center of the new object with middle mouse button / left alt + left click. Then move the mouse to select the object radius and click the same button. After that, move the mouse to set the speed vector of the new object and click the same button again. If another object is selected, then after new object creation its location and velocity will be set relative to the selected object.
- /save - save the current layout with the name "filename", the file "filename.planets" will appear in the same folder
- /load - load the saved layout with the name "filename", it is possible only if the file "filename.planets" is present in the same folder
- /clear - clear the layout, reset scale and time speed
- /random - clear the layout, reset scale and time speed and put 1000 random objects
The program uses SFML for graphics. To run calculations most effectively, it runs them in a dedicated thread, while the other one is responsible for graphics and controls.
The same simulation, but relatively to Earth: