If you are talking in a 2D world just apply a 9.8metres per sec accelerating vector down.
However when you say it doesn't work what sort of results are you getting? you'd have to remember that the earth is massive compaired to objects on it which are close so it has some force. If you are giving 3d objects little mass and putting a fair about of space between them and expecting gravity to do much that might be a problem.

Proper gravity only really has a place in space games. If that's what you are doing:

The gravitational force one object exerts upon another is indeed given by the formula you quote.

To get the total gravitational force vector on a given object (theObject), you need to sum the forces of each object that exerts a pull. To get the force vector exerted by someObject:

* calculate a unit vector pointing from theObject to someObject.
* calculate the gravitational force using your formula.
* multiply the two together.

As you go through the other objects in the scene, add their contributions to a running total, and then apply the total force to the object in question.

Please note that the above is crying out for optimisation. Two main things:

1: it's probably faster to calculate the gravitational field at the point, since one doesn't have to worry about the affected object's mass at any point, and

2: you certainly don't want to bother summing the contributions of individual spaceships, unless they're very very massy spacecraft very close to one another indeed. I'd suggest some cutoff point, at a large number of kilograms (say 10,000,000Ö at least), where anything massing less is not considered in the calculations.