GOAL: Land each puppy on the moon. Each time a new puppy will appear. Use the arrow keys to activate puppy thrusters. Use A to speed it up towards you (away from outer space). Use S to speed it up away from you (into outer space). * FOR PUPPY LOVE. No it's not done, but I thought Id make it public anyway.
Soundtrack is "Mid-December Understanding", an original piece I recorded on digital piano. This game illustrates simulated orbiting around a 3D center of mass, using Newton's gravitation equation: F=G * m1 * m2 / r*r F : Force of gravity G: Gravitational constant (just a fixed "magic" number) m1, m2: The mass of items 1 and 2 r : the distance between the two items (actually their "centres of mass") In this program, for simplicity, we combine G * m1 * m2 into an artificial constant "grav", because they are all constants. ("grav" uses arbitrary units at this point.) So we have: F_grav = grav / dist*dist Now we know the gravitational force (again in arbitrary units at this point), we calculate acceleration using Newton's law: F = m * a So we have: a = F_grav / m We update the 3 velocity (speed) variables v_x, v_y, and v_z by a value proportional to F_grav (gravitational force). Limitations: The equations are just approximate, constants are fudge factors, forces are sampled at discrete times so its not accurate, the perspective is handled in a very simple way (z coordinate corresponds to size of puppy), units are arbitrary. Its just for illustrative purposes =D No puppies were harmed in the creation of this game!