Javascript gravity simulator!

This is a DHTML gravity simulator I threw together in Javascript as an exercise. Hence the name "javascript gravity simulator". To add new planets click and drag, the further you drag the faster they will go. To clear all the planets press 'c'.

I'm aware that this isn't written in the best way that it could be, this is partly due to the fact that I don't know how to do that Runge-Kutta thing and that wasn't the point of this exercise (therefore it's all Euler). Also, I calculate the forces on each planet twice, so it is probably slower than it needs to be for that reason. Finally, the collisions were a quick hack and don't work at all like one would hope/expect. Oh well, if you don't like it make your own damn simulator!

Finally, I've only tested this in Firefox 2.0 and Safari. As such I have no guarantees about its behaviour in other browsers. Luckily if you desperately need to see planets in javascript, Firefox is free! So again, don't complain.

Send spiffy emails to jsgrav<@>wxs<dot>ca.

A project by W. Xavier Snelgrove