Games Demystified: Super Mario Galaxy

Gamasutra is starting a new series called Games Demystified. They’ll be deconstructing games with unique or distinguishing mechanics that may have left some folks scratching their heads, including reproducing effects with code samples, examining — just how did they accomplish that? The first game we’ll be covering is Super Mario Galaxy for the Nintendo Wii.
Upon release, Super Mario Galaxy enchanted the gaming community because it allowed gamers to walk upside down and inside out — all while feeling completely intuitive. Especially geeky message boards and blogs have lit up with people attempting to apply real-world physics equations for gravity to each of the game’s tiny planetoids.
Obviously, real world physics have a place in today’s games. However, they take a backseat to psychology when it comes to making real world gameplay. In reality, mass distorts the fabric of time and space causing gravity, the force that keeps us stuck to Earth.
The important thing for the game is that we expect to get pulled toward planets — and in fact, Mario does get pulled to each and every strangely shaped planetoid in the game.
Normally, gravity is calculated as a force between two objects that is directly proportional to the product of their respective masses and inversely proportional to the square of the distance from the objects’ centers.
Force of Gravity = Gravitational Constant * ( ( mass1 * mass2 ) / distance2)
To simplify, gravity follows the inverse square law.
Intensity of Gravity = 1 / Distance2
This means that as an object moves closer to a planet, the gravity between them increases exponentially. Conversely, as an object moves away from a planet the gravity between them weakens very quickly.
(Demoed in the video above):
Calculating real gravity on a surface like this would be a task best left to Stephen Hawking. However, for the game to play correctly, the developers merely had to cast a ray relatively down from Mario’s local center and grab the nearest surface normal.
Inside any 3D game engine worth its salt, there is a list of all polygons being rendered on screen and we can retrieve the first polygon that our ray cast intersects.
That polygon in this case represents our plane and the inverse of its surface normal represents the direction of gravity that will pull Mario smoothly back to the planetoids surface. That polygon’s surface normal is also used to align Mario to the curvature of the planetoid.
Download the .exe used in the video above
Visit Gamasutra for the entire article, which goes into great detail

$49.99
Buy Super Mario Galaxy from WiiNintendo’s Store








Comments