Advanced gravity (with mass)

I want to make game similar to Space Tanks after finishing my current project. Space tanks is pretty much tanks/scorched earth type of game except you are in space and have to consider gravity fields of different celestial bodies (mainly planets though). Another good example of such game is Slingshot game for GNU/Linux.

The problem is that I am unable to find out some physics algorithm that would allow for more advanced gravity than moving objects down/up or on either of sides. Build-in physics seems to be standard Box2D which doesn’t have such functionality to my knowledge.

You can simulate gravity by adding a force to each object toward a position : (6.28 KB)
( Don’t be afraid by the message saying that the game was made with a newer version of GD )

Thanks! Works like charm!

//edit: Can you help me update force formula so it’d also consider mass of object (in kg, stored in object variable)? So bigger planets will have greater gravity.
Current formula:

Increase the force ( i.e. its length ) according to the object mass, like this :