2D Universe Physics

A demo of simple gravity effects and trajectory plotting.

Left and right arrows to change number of planets.
Space to generate new layout or update planet count.
Click to fire.
The gravitational effect of the planets on the ship uses the formula

My simulation assumes the space ship has a mass on 1, therefore can be ignored in the calculation.
To plot the trajectory before launch I just simulate an entity with the same properties as the space ship for the number of steps I want the trajectory to preview. You could probably improve the speed of the simulation by storing the predictions and assigning them to the spaceship on launch rather than re-calculating (that's what currently is happening). Repository