Farseer Physics Engine

Recently, I have started to get ready to create a retro inspired 2D platformer game and as part of this I was looking for a physics engine suitable for use with MonoGame.

It seems that Farseer is the most popular library for these kind of things out there and there are samples included in MonoGame Samples project on GitHub. Those samples are targetting OS X, but adapting them for iOS is not difficult:

  • I had to re-generate some of content files to get them to load (it seems that spritefonts are a bit quirky on iOS) which is easy to do with MonoGame Content Project. But you better do so on a Windows 7 machine as it requires some parts of XNA Game Studio that require a bit of hacking to get them to work on a Windows 8 machine. I prefer to leave my Windows Phone development environment as it is so I used a Windows 7 virtual machine.
  • And you have to touch enable everything which was a breeze as the samples are beautifully written and easy to read.
    • The end result is this:

      Very nice! and all the collision detections and bouncing of the car and so forth is managed by Farseer! All you have to do is define a World, define its gravity, add some bodies to the world and specify their weight, define any relationships between objects such as how the tyres of the car are related to car chassis and so on. Very neatly done!