Fullscreen recommended. Use turbowarp or forkphorus, and turbo mode, if you want anything to happen in less than a million years. Seriously, you will not even see it moving if it’s not in turbo mode. Planned features list/final product description: (not 100% implemented yet, but the N-body simulation part is operational, and the spaceship is sort of okay, but still much work there is needed). It’s an n-body gravitational simulation featuring planets that will orbit each other (or just smash and blow up), with collision physics included. (I have started implementing this, but I have it disabled so far). Planets loop around the edges of the space to stay on the screen. The red cross marks the barycenter. (also WIP) The number at the bottom shows time. It’s also gamified so you can fly a spaceship around the planets and possibly orbit them (the planets orbit each other, but the spaceship feeling gravity isn’t implemented yet), or maybe smash into them to impart momentum (not yet implemented), to keep your solar system from collapsing. It’s a WIP, and actually you can’t actually interact with the planets yet. So far you can only control the spaceship as if floating in empty space, and you don’t feel the planets’ gravity yet, sorry :( Spaceship controls: <- and -> for rotation, and ^ for forward thrust. Autopilot controls are: p for prograde, r for retrograde, s for cancel angular momentum, and v for cancel velocity. (unfortunately these features are not very smart and tend to oscillate around the correct point because they keep overcorrecting and then having to go back.) If you find bugs, glitches, or generally any mistakes, please tell me so! It would be very helpful. Also, feel free to try tweaking the code and parameters for the simulation and see what else you can come up with! Remixing is allowed. Known bugs: Due to how the simulation works, orbits will tend to drift upwards slightly, leading to a loss of accuracy over time. For this reason (and possibly a few others, too), the simulation can end up violating energy conservation. The planets tend to get higher and higher velocities, and eventually they’re all moving too fast to orbit each other, and it basically becomes a hot soup of planets. This is somewhat amusing, but not exactly accurate. But it’s only an alpha, so I guess it’s okay. It will hopefully be fixed at some point. Also, the collision physics is only half-written and doesn’t work completely yet. Also, planets colliding gain more velocity than expected, and eventually just smash around the screen like crazy. Also, the simulation often glitches for a second when they collide. And they don’t always collide when they’re supposed to. (hopefully shall be fixed soon…) In light of this situation, I have temporarily made the collision physics off by default to work on the rest of the project without it lagging and crashing. Once I update the collisions, I will make them on by default. simulation.
Feel free to explore the source code by yourself. There are a few helpful comments, and I tried to give the variables and functions descriptive names to make it easier to understand (and update). Thanks to some website with spaceship icons for the rocket image. Special thanks to my dad, who helped me debug some critical parts of the simulation and who taught me most of these formulas in the first place.