Downhill Supreme - iOS mountain bike game

Downhill Supreme is a mountain-bike game for iOS, in the App Store now. The game was developed with collaboration from leading manufacturers of kick-ass frames and parts, so all the branding is legit 🙂

https://itunes.apple.com/us/app/downhil ... d648104417

Image

The bike and rider model is very complex, with 22 bodies and 50 joints, but Box2D performs well and everything runs at 60fps on iPod3G. Although there are many parts to the model, in reality there are only four bodies that play a major role in the gameplay: torso, bike frame, and wheels. These four bodies have real-world values for mass (75kg, 15kg and 2kg respectively) and all other bodies in the structure are extremely light so that they have almost no influence on the behavior of the bike, and merely go along for the ride, to provide a location to draw the textures. A wheel joint connects each wheel to the frame, and four distance joints connect the frame to the torso. The length of these distance joints is changed to make the rider lean. The rear suspension for each frame type does have a unique linkage modeled, but again, this is only for display and does not affect the simulation. Since the rear wheel moves up and down in a straight line (on the wheel joint), and the linkage wants to rotate, the position of the wheel center and the hub point on the swingarm do not always match up, but it's hard to tell while playing.

R.U.B.E editor was used to build the bike model and tracks, and lay out the menu screens too.
Image

More info here: http://www.downhillsupreme.com/
Good work, especially modeling the actual dimensions of what you are simulating. Did the 3D to 2D mapping throw off any numbers outside of your intuition or was that part straightforward?
Not sure what you mean by 3D to 2D mapping... the ground mesh is indeed 3D, but it's just automatically generated from the ground line, and all points in the generated mesh are below the original 2D line. So if anything, it's more like a 2D to 3D mapping. The bike rides along the original line, and the 3D mesh is rendered with a very narrow field of view (5-20 degrees) so that the bike does not look so out-of-place (being completely flat) and to make sure the mesh does not obscure the bike when it's at the sides of the screen.

But perhaps you're talking about the part that did give me a real headache - figuring out how to go from using the dead-simple glOrtho to define a rectangle of the world to draw, to using glMultMatrix to get a 3D perspective projection that would look at the same rectangular portion of the z-plane, while having the fov freely adjustable. No, that was not particularly straightforward...
Here is a video:
http://www.youtube.com/watch?v=OL66G3JLYvA
irresistible force: I've been really enjoying Downhill Supreme 🙂 It gets quite challenging!

Question: how did you do the restore to checkpoint feature? It looks like you've managed to save the exact state of the entire bike allowing the player to seamless restore and continue on exactly as they went through the checkpoint.

How are you saving this state? What information about each body do you save? Do you have to save state for every body and joint on the bike??
You need to save the
- position
- angle
- linear velocity
- angular velocity
... of all bodies. Joints don't really have any state to speak of (eg. the 'speed' of a revolute joint is really defined by the relative angular velocity of the two bodies it connects), so nothing is saved for joints. For joints that have motors, you might need to save the motor setting if that's important in your game, but for our game the motor state is updated every step from the current input, so it was not saved.

Original thread: https://box2d.org/forum/viewtopic.php?t=9314