The Problems with Space and Gravity
The problem with space is that it is too damn big. Bill Bryson covers this far more eloquently than I ever could, in his book A Short History Of Nearly Everything. In it he uses the analogy of trying to draw a solar system on a piece of paper and the scaling required for correctness. It turns out trying to show the earth and the sun on the same piece of paper, to scale, is a fruitless task due to the fact that the distance between the Earth and the Sun is almost 12,000 times the diameter of the Earth. Wikipedia (please donate!) also has an interesting article on solar system models.
In our first flash game, Celest, we want to simulate orbiting in the gravity fields of various large planets including planets that are orbiting each other. To fit properly scaled planets and a ship on the same screen would require a planet larger than the viewable area and a ship smaller than a pixel. This is a problem since that would not work inside the realm of this game.
The current size scaling is not even informed by reality. A space ship with a size roughly half that of the planet but only weighing a tenth of a kilo compared to a planets 10^7 kilos is a very strange relationship for these objects to have in real life, but in Celest with only a 800×480 display it is almost necessary for the game to be playable.
Even once scaling is resolved, by tweaking the size, masses, and gravity to make Celest playable, another problem with gravity scaling arises. Planets are so massive that while they create the correct gravity at reasonable (for gameplay) ranges for our little spaceship, if the planets are allowed to orbit each other, the gravity is so great that it always results in a rapid cataclysmic collision of the planets for any reasonable distances and speeds. Because our scales are so out of proportion with reality (planets are so much vastly closer in our game than in reality) our gravity cannot be universal. To solve this, in our simulation we cheat and use a different gravity calculation for planet to planet interaction so that the planets can orbit each other at reasonable speeds and be on the same low resolution game screen. To make it easy to program we actually do not take into account the planet’s masses multiplied by a gravitational constant. Instead we simply say that planets have a universal attraction with each other regardless of masses. This allows us to ensure that the dynamics in planet-planet interaction are very predictable.
I am not entirely happy with this because it would be neat to be able to adjust the dynamic between the planets based on their masses, but this would require a significantly smaller gravitation constant than the one used to calculate ship’s gravity with the planet. Perhaps in the future all types of objects will define a separate gravitational constant for each type of object in the game. This should allow us to tweak planetary interaction with their masses, while still avoiding planetary collisions.

May 8th, 2008 at 5:27 pm
Did you consider having a separate active gravitational mass and passive gravitational mass? One of the weird things about mass is that the same term appears in three fundamentally unrelated (by Newtonian mechanics anyway) contexts: inertial mass (F=ma), active gravitational mass (exerts a force on other masses), and passive gravitational mass (feels the force from other masses). If the passive gravitational mass of the planets were significantly smaller than their active gravitational mass, they would feel significantly less force from the other planets than the spaceship would. The formulation would be F (this planet) = G * (passive gravitational mass of this planet) * (active gravitational mass of the other planet) / R^2. This would be the equivalent of having a smaller G between planets without having to change G.
May 12th, 2008 at 8:38 am
That sounds like a better solution than the one that I implemented or the one proposed. I hadn’t thought about a passive vs active gravitational effect before; it is an interesting idea to split the idea of mass into mass effecting others and mass effecting me. It makes me curious if the passive could be defined as a percentage of active and have that be set on each class.
Excellent comment! *would buy again*