Wednesday, March 4, 2009

Gravity Game

My latest hobby project is a gravity-based game in the tradition of old classics like Lunar Lander, Gravitar and Thrust. Currently, the mechanics are pretty simple. Shoot things, avoid being shot, crashing, or being hit by an asteroid, and use your tractor beam to move around colored balls that act as keys to remove barriers.

I've also been playing with water dynamics.

The game is XNA-based, and I'm using Farseer as my physics engine.

1. Cool, an update! Can you go flying around the planet? Like even "under" it and the gravity be reversed? Would sure be cool.

2. Hi Alex - yes, gravity is always toward the center of the planet. I keep it from increasing when you go underneath the planet's surface, though - otherwise it would get too strong.

3. where to click to play?

4. Here's a brief explanation of the actual physics for gravitation beneath a planet's surface (Newtonian):

The quantity of force experienced by an object as it moves beneath the surface of a massive sphere is equal to the force which would be produced by a smaller sphere with radius equal to the distance from the object to the center of the sphere.

Thus the force actually diminishes, slowly approaching zero, as you you move closer to the center of the planet and the direction of the force is always toward the center of the planet.

Basically the math tells us that the part of the planet that is "above" the object gets exactly cancelled by the corresponding part of the planet at the same radius on the opposite side. Thus the only net force is from the remainder of the planet "below" the object.

5. Thanks for the info, Waylon. It makes sense when you think about it.