Monday, October 8, 2012

Farseer Physics for Windows Store Apps using Monogame

  Last week I did a session on porting XNA Windows Phone 7.x games to Windows Store apps using MonoGame. I have to thank Dean Ellis from the MonoGame project team for all the help. 
 While XNA is not a framework directly supported by Microsoft for Windows Store apps the current version of MonoGame is compatible with Windows 8 and, the most important thing, the applications pass the WACK. There are already several games available in the Windows Store developed using MonoGame (Armed, Skiddy, Rune Legend and I guess there are more). 
   For the session I ended up using the Simple Animation sample but seeing how easy is to share the code between the platforms (Windows, Windows Phone,PC, MAC, iOS, Android, Playstation, Linux) I started looking for a physics engine. The most used Open Source physics engine seems to be Farseer Physics but it was too late to do the porting for my session. On Sunday I tried the porting and everything went pretty smooth. The only thing I've changed was the serialization/de-serialization of the "World" state. I compiled the engine and also the sample. For the Sample project the Content Project was compiled using Visual Studio 2010 (for the moment Visual Studio 2012 doesn't recognize this type of project) and added the xnb's to a Content folder inside the Visual Studio 2012 solution. 
 You can see the result in this YouTube video:


I've used SnagIt to capture the movie and it influenced the frame rate (when running without capturing the framerate is always at 60 fps). The test device was the Samsung Slate which has a powerful cpu. I would love to know if a WinRT device will be able to run at the . If any of my readers has access to a WinRT device please deploy the sample to the device and let me know if the framerate is as expected. For the sample you will have to use an external keyboard and mouse as the touch screen is not working in this version. I will try to fix it for the next release (the problem seems to be inside the MonoGame framework as I only receive the move event and not the pressed and released from the touch screen).
   
Use this link to download the full project (engine and sample): 

NAMASTE





4 comments:

  1. I have an RT device if you still need to test.

    ReplyDelete
  2. Without you, I haven't figured out my problem about the Vector2 thing of Farseer when transfered to a Windows8 project. it's good you recompiled it for it to work!

    ReplyDelete
  3. Very good news for me! Thanks for your post. :)

    ReplyDelete
  4. Lovely stuff, saved me an hour or 3

    ReplyDelete