{"id":20845572,"url":"https://github.com/ineido/space","last_synced_at":"2025-05-09T02:45:38.291Z","repository":{"id":52518686,"uuid":"359830982","full_name":"INeido/Space","owner":"INeido","description":"Doesn't do much. Just some bodies flying around in the void.","archived":false,"fork":false,"pushed_at":"2023-01-20T16:38:52.000Z","size":28603,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-31T21:33:32.387Z","etag":null,"topics":["gravity","nbody-gravity-simulation","pygame"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/INeido.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}},"created_at":"2021-04-20T13:44:21.000Z","updated_at":"2023-01-20T16:41:52.000Z","dependencies_parsed_at":"2023-02-12T03:45:23.238Z","dependency_job_id":null,"html_url":"https://github.com/INeido/Space","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/INeido%2FSpace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/INeido%2FSpace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/INeido%2FSpace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/INeido%2FSpace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/INeido","download_url":"https://codeload.github.com/INeido/Space/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253181098,"owners_count":21866988,"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":["gravity","nbody-gravity-simulation","pygame"],"created_at":"2024-11-18T02:13:19.839Z","updated_at":"2025-05-09T02:45:38.271Z","avatar_url":"https://github.com/INeido.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Space\r\n\r\n\r\nDoesn't do much. Just some bodies flying around in the void.\r\n\r\n## Settings\r\n\r\n| Name | Description | Standard Value |\r\n| ------ | ------ | ------ |\r\n| FPS | Pretty self explanatory, isn't it? | 120 |\r\n| drag | \"Air\"-Drag, but in space | 0.000001 |\r\n| coll_loss | Loss of speed on collision | 0.000001 |\r\n| res_x | Changes the screen width | 1920 |\r\n| res_y | Do I have to tell you? | 1080 |\r\n| zoom_factor | Zoooooooom | 0.98 |\r\n\r\n## Switches\r\n\r\n| Name | Description |\r\n| ------ | ------ |\r\n| trace | Enables cool effect |\r\n| edges | If enabled, bodies can't escape screen |\r\n| gravity | The thing with the apple |\r\n| collision_color | Bodies change colors on collision |\r\n\r\n## Controls\r\n\r\n| Button | Description |\r\n| ------ | ------ |\r\n| ESC | Closes game |\r\n| E | Resets bodies |\r\n| S | Toggles between **Insert** and **Focus** mode |\r\n| Left Click | Follows body when clicked (Focus) |\r\n| A \u0026 D | Switch between bodies (Focus) |\r\n| Left Click | Gravitational pull at cursor (Insert) |\r\n| Right Click | Gravitational push at cursor (Insert) |\r\n| Middle Click | Drag screen (Insert) |\r\n\r\n![](https://github.com/INeido/Space/blob/main/img/gif1.gif)\r\n\r\n## Examples\r\n\r\nKinda stable orbit with 3 bodies\r\n```\r\nbodies.append(Body(p=(0, 300), v=(3, 0), r=5, c=white))\r\nbodies.append(Body(p=(0 + 150, 200), v=(3, 0), r=5, c=white))\r\nbodies.append(Body(p=(0, 0), r=75))\r\n```\r\n\r\nNot really stable orbit with 2 bodies\r\n```\r\nbodies.append(Body(p=(100, - 100), v=(3, 2), r=25, c=white))\r\nbodies.append(Body(p=(0, 0), r=50))\r\n```\r\n\r\n2 bodies on collision course\r\n```\r\nbodies.append(Body(p=(-600, 0), r=50, v=(3, 0)))\r\nbodies.append(Body(p=(600, 0), r=50, v=(-3, 0)))\r\n```\r\n\r\nCreate any amount of random bodies defined in **count**. (Don't recommend more than 50)\r\n```\r\ncount = 10\r\n\r\nrand = random.choices(population=[[\"5\"], [\"10\"], [\"15\"], [\"20\"], [\"30\"]],\r\n                      weights=[0.35, 0.30, 0.20, 0.1, 0.05],\r\n                      k=count)\r\n\r\nfor x in range(count):\r\n    bodies.append(Body(p=(random.randint(-res_x / 2, res_x / 2),\r\n                          random.randint(-res_y / 2, res_y / 2)),\r\n                       v=(random.randint(-5, 5),\r\n                          random.randint(-5, 5)),\r\n                       r=int(int(''.join(rand[x]))),\r\n                       c=white))\r\n```\r\n\r\nYou can paste these into the **reset** function.\r\n\r\n![](https://github.com/INeido/Space/blob/main/img/gif2.gif)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fineido%2Fspace","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fineido%2Fspace","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fineido%2Fspace/lists"}