# physics of 2D car racing game with heightmap

I want to develop a simple car racing game where the road is defined by a heightmap. It looks basically like this:

The player can use throttle and brake to control the car.

I'm wondering what the best approach for the physics is. I have some ideas:

• Use a mass-spring system with one mass for each wheel.

Pro: Gravity affects each wheel independly, so if one wheel stands on ground and the other one floats in the air, the car rotates. Can be extended to three dimensions by adding two more wheels.

Contra: The distance between the weels varies. The system may explode (when forces amplify each other). The car will fall down if both wheels float, but the middle of the car touches ground.

• Define the car's state using position, momentum, rotation and spin.

Pro: The wheel distance is constant, no springs included

Contra: very complex, hard to compute, not really extensible to a third dimension

I think there must be a better way than those.

-
"Later, I want to add a third dimension" What? – Liosan Feb 1 '13 at 9:23
I hope I can use the same technology (or at least the basic idea) in a three-dimensional race game later. – Yogu Feb 1 '13 at 9:27
Ok, forget the thing about third dimension, it was only an idea... any constructive comment? – Yogu Feb 1 '13 at 21:11
How did you come up with the Pro and Contra arguments? Using rigid body physics is actually easier and more stable than tweaking stiff springs for your car (and it won't be very pleasant). Undoubtedly, Box2D can do the hard work for you: emanueleferonato.com/2009/04/06/two-ways-to-make-box2d-cars . – teodron Oct 16 '13 at 16:07
Thanks, @teodron! The second example was exactly what I was looking for. It uses springs, but I don't know if they are required. – Yogu Oct 16 '13 at 17:26