JavaScript Gravity

Here is one of a few little JavaScript pages I'll be adding to the site as I build together a few components to create my own little JavaScript game.

This first step towards the game is to create the effect of an object subject to gravitational pull. This is not a simulation of the force of gravity by a long stretch but it does give the effect of gravity and that's all I wanted it to do.

Just click the link below to have a play with it. You will see a small object at the bottom of the browser and some input box's in the top left corner. In the input box's you can put the speed at which the object is fired and the angle you wish it to reach in the sky (so to speak). Also you can select to turn the objects trail on and off to see where it has been on the screen, like in the image below.

Gravity Picture

Anyway enough chit chat click here to give it a go.

Tested to work in the following browsers;

  • IE 7
  • FireFox 2.0.0.3 (See bugs)

Known Bugs: Sorry Opera user's but this one just doesn't want to work in Opera. In saying that it does work but it suffers from extreme flickering!.
Also in Fire Fox a slight annoyance in that it doesn't keep focus on the object as it flies off the screen if you make it go really far.


Last Updated : 02 May 2007