{"id":24503966,"url":"https://github.com/mostlime12195/n-body-simulation","last_synced_at":"2026-05-21T04:07:26.029Z","repository":{"id":272142114,"uuid":"915628430","full_name":"Mostlime12195/N-Body-Simulation","owner":"Mostlime12195","description":"An N-Body Simulation made with Raylib and C++","archived":false,"fork":false,"pushed_at":"2025-01-19T14:02:44.000Z","size":104,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-19T15:18:57.422Z","etag":null,"topics":["cpp","gravity-simulation","nbody","nbody-simulation","opengl","raylib","raylib-cpp","simulation"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Mostlime12195.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-12T11:37:36.000Z","updated_at":"2025-01-19T14:02:45.000Z","dependencies_parsed_at":"2025-01-12T13:40:28.998Z","dependency_job_id":"8d2839ef-e7df-4035-ab87-6a28a61d3f0f","html_url":"https://github.com/Mostlime12195/N-Body-Simulation","commit_stats":null,"previous_names":["mostlime12195/n-body-simulation"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mostlime12195%2FN-Body-Simulation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mostlime12195%2FN-Body-Simulation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mostlime12195%2FN-Body-Simulation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mostlime12195%2FN-Body-Simulation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Mostlime12195","download_url":"https://codeload.github.com/Mostlime12195/N-Body-Simulation/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243704256,"owners_count":20334121,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","gravity-simulation","nbody","nbody-simulation","opengl","raylib","raylib-cpp","simulation"],"created_at":"2025-01-21T23:19:16.225Z","updated_at":"2026-05-21T04:07:26.003Z","avatar_url":"https://github.com/Mostlime12195.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# C++ N-Body Simulation\nThis N-Body Simulation is compiled in C++ and Raylib. \n\nFeel free to use this repo for your own use.\n\n## Features\n- Barnes-Hut model\n- Adjustable simulation bounds by modifying `minX`, `maxX`, `minY`, and `maxY` variables in the source code.\n- Dynamic visuals with color-coded particles representing energy levels (blue to red), grid overlays, and a contrasting UI.\n- Inelastic collisions (modifiable via code)\n- Spawn particles in-game with velocities and directions of your choosing\n- Hold mouse down to select what mass of particle you would like to spawn\n- Adjustable number of particles to spawn on start\n- In-game gravity manipulation\n- Multi-threading capabilities\n\n## Compatibility\nThe project was compiled with -Ofast flags, significantly increasing performance, but this means that your system must have AVX instructions. Most CPUs made in the last decade have AVX instructions.\n\n![image](Assets/thumbnail.png)\n\n\n# Controls\n\n### Particle Interaction\n- Left click anywhere to spawn a particle.\n- Left click and drag to spawn a particle with a direction and velocity.\n- Hold down Left click in order to select your particle's mass.\n\n### Camera Controls\n- Hold right click to pan the camera.\n- You can also use the arrow keys to pan the camera.\n- Use the scroll wheel to zoom in and out with the camera.\n\n### Simulation Adjustments\n- The '[' button halves Gravity while ']' doubles it.\n- Press C to toggle collisions.\n- Press P to toggle whether or not you want to automatically spawn particles on start/restart.\n- Press R to restart the simulation.\n\n### Exit\n\n- Esc button to leave the game.\n\n# Important notes\n\n- This is an amateur project.\n- This project is EXTREMELY terribly made. \n- Particles in the center of large\u003csup\u003e[1]\u003c/sup\u003e clumps may exhibit instability due to unoptimized handling of extreme interactions. This is a known limitation and may be addressed in future updates.\n\n\u003csup\u003e[1]\u003c/sup\u003e Smaller clumps collide perfectly correctly.\n\n# Future Improvements\n\nThis is a todo list of improvements I am planning on implementing as the project grows.\n\n- [x] Barnes-Hut model (Allowing for millions of particles)\n- [ ] Better parameter adjustment UI\n- [x] Coloured controls in UI for readability and accessibility\n- [x] Multi-threading support (currently it has a very basic implementation)\n- [ ] Sound effects on collision\n- [ ] Individual particle manipulation\n- [ ] MacOS/Linux export\n\n### Not planned\n\n- Web export (Extremely difficult to do, decreases performance significantly, limitations and issues with multithreading)\n\n# How to compile\n\n## For VSCode\n\nThis project contains a .vscode folder with configurations. Just make sure that you have Raylib and g++ (a C++ compiler) properly installed. Also, add this code to your `.vscode/c_cpp_properties.json` file, create it if it doesn't exist:\n\n```\n{\n    \"configurations\": [\n        {\n            \"name\": \"Win32\",\n            \"includePath\": [\n                \"${workspaceFolder}/**\",\n                \"C://raylib/raylib/src\"\n            ],\n            \"defines\": [\n                \"_DEBUG\",\n                \"UNICODE\",\n                \"_UNICODE\"\n            ],\n            \"windowsSdkVersion\": \"10.0.22000.0\",\n            \"compilerPath\": \"cl.exe\",\n            \"cStandard\": \"c17\",\n            \"cppStandard\": \"c++17\",\n            \"intelliSenseMode\": \"windows-msvc-x64\"\n        }\n    ],\n    \"version\": 4\n}\n```\nAlso, these directions assume you have everything installed in the default location.\n\n## For Notepad++\n\n### If you use Raylib's given Notepad++\nYou can find Raylib's Notepad++ inside of the raylib installation directory. Then you can find `notepad++.exe` under the `npp` folder.\n\n#### Steps\n1. Open main.cpp (with Raylib's version of NP++) \n2. Press f6 \n3. You'll see a list of commands. One of them should be `SET CC=gcc`. Replace `gcc` with `g++`. If it's already like that, continue to the next step.\n4. Click on 'OK'.\n5. You're done!\n\n#### Notes\n- `gcc` must be replaced with `g++` because the project does not work with a C compiler (`gcc`), and thus you must compile it with a C++ compiler (`g++`) instead.\n\n### If you use any other edition of Notepad++\nI have not compiled this project under any other version of NP++, so I suggest that you either use Raylib's NP++, or you search for help elsewhere online.\n\n## For any other IDE/Text editor\n\nUnfortunately, if your IDE or text editor is not mentioned here, that means I have not compiled my project with it. You can find articles online detailing how to compile it on your system or IDE.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmostlime12195%2Fn-body-simulation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmostlime12195%2Fn-body-simulation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmostlime12195%2Fn-body-simulation/lists"}