An one-button way to control the player coming from the past – Box2D version (introducing friction joints)

This is a quick attempt to port the engine of the one-button way to control the player coming from the past using Box2D, introducing for the first time the friction joint, a type of joint which is poorly explained in the tutorial you can see around the web, and it’s a pity because it’s very useful when you have to handle with top down simulations.

Basically I created a world with no gravity, then I created a friction joint between the ball controlled by the player and the “ground”, in this case the world body.

The final result is a lot more realistic than any other result you can achieve using linear damping or other tricks.

This is the source code:

and this is the result:

You know how to “play”: press and keep the mouse pressed to move the ball with a given direction and speed. Also look at the friction joint in the debug draw.

Download the source code

  • Dex

    I love where this is going! Please, continue with the series :)