Farseer Physics in Blitzmax Demo

Hurray! Finially got to a stable stopping point in porting over Farseer Physics from C# on XNA to Blitzmax! Farseer Physics Engine is a 2D physics engine originally written by Jeff Weber who develops XNA/Silverlight games over at Farseer Games. Much thanks to him for creating a great physics engine and for allowing me to move it to another language, which once done, I hope will help others create fun physics games in Blitzmax.

I’ve ported the ‘core’ features of the engine which now would allow you to use the basic features of the engine. If you head over to the Codeplex Farseer Physics Page you’ll see a list of the features in the C# version of the engine. Right now the things that aren’t implemented in the Blitzmax version:

  1. Fluid Drag and Buoyancy Controller.
  2. Slider (Prismatic) Joint
  3. Pin (Distance) Joint
  4. Broadphase Colliders: SweepAndPrune, BruteForce
  5. Collision Callback Mechanism

Currently, the Blitzmax version is using the ‘SelectiveSweep’ Broadphase collider that is the default collider in Farseer, and is supposed to have the best performance in a wider range of scenarios. The others have their advantages and disadvantages based on specific situations in the physics environment. I’ll be implementing those as well along with the rest of the list, but they weren’t used in the current build of the C# Farseer demo application so I chose to focus on the needed classes first to get an identical demo app running in Blitzmax.

Just some metrics you may find interesting (as I’ve noticed typical Blitzmax users have a very different way of developing their games):

84 .bmx files used for the physics engine and the demo application
7957 lines of code (blank lines not included)

Sounds like it may be a lot, but in reality it really isn’t much compared to a full relatively complex commercial Casual, Indie, or AAA game. But the reason I put that up there is to illustrate a point. I feel like if I was using the default Blitzmax IDE I would’ve have one hell of a nightmare just handling these little files. Having a project of a much bigger scale in BlitzPlus in the past, I know from experience the headaches of a large monolithic code base. You spend a lot of time scrolling and searching through files because the IDE promotes that type of behavior from the get go. Using BLIde, a very flexible editor created by Manel Ibรกรฑez, productivity went way up and I was able to get more done on the physics engine. Not to mention built in Intellisense support is a god-send, which lets you spend more time coding instead of reading API docs. Just that feature alone I think is enough to abandon the default IDE and stick to BLIde. Anyway, if you’re a Blitzmax user I highly recommend that you take the time to learn to use BLIde and support Manel’s efforts for an outstanding product!

I’ve uploaded a demo video showcasing the same demos available in C# running in Blitzmax. I also added a new and original demo by me showing the use of concave polygons, which is one feature many 2D physics libraries lack. With other physics engines you can emulate concave shapes by putting together a bunch of convex ones, but it’s still a cumbersome and tedious task. The ability to create concave shapes with minimal hassle is a great productivity boost for content creation in your game. Below is a video of the physics demo app, along with a download link to the demo app itself so you can run it on your own PC. Hope to have more info posted with updates in the coming weeks!

To download the demo application shown in the above video click below:

Download Farseer Physics Demo


– Windows XP/Vista
– Direct X 7 or higher capable video card
– Minimum supported screen resolution: 1024 X 768

Known Issues:

– In Vista the fps are lower (and in some demos locked to 60 instead of 100 fps).


  1. Hi Alex

    I’m very interested in Physics engine and already have my preference with Box2d which is currently wrapped by Brucey in the blitzmax community.

    I already play with Farseer in C# and find it very powerful (mainly with concave shape collision).

    It’s a very good idea porting it to Blitzmax ! I didn’t even know it was possible to do such with .net project. Did you rewrite the whole source (?) or wrap a precompiled library ?

    I was having good FPS running your examples (like 105fps on a 64×2 3.8ghz AMD 2go Geforce 7600se) but my impression was that it was a bit slower than the Farseer examples…

    Is this bmx module is fast enough to handle “now days” games physics based (Like locoroco, gish, tower of goo and similar with a indie 2D look) ?

    Finally what’s your main idea with this module ?
    Open source / Shareware / Freeware / License ?


  2. Hi Arme,

    Box2D looks like a great 2d physics engine. I believe Brucey is working on the 2.0 port (which includes continuous collision detection!).

    The port of Farseer to Blitzmax is pretty much a re-implementation into 100% Blitzmax. There are no outside dependencies besides a basic blitzmax install.

    What made you have the impression that the examples were running slower on the Blitzmax version? Was there a graphical stuttering or something? My goal is to make it as close as possible performance-wise to the C# version. Visually right now, for higher-end machines there’s no difference. It’s the lower end machines that are taking a bigger hit obviously. There are slight differences in performance right now that I’m trying to optimize as much as possible. There is about 1-5 ms difference between C#/Blitzmax on the more stress-test centric demos. The thing with XNA, is due to it’s higher requirements VS Blitzmax, it tends to work very well on most PC’s that can run XNA at all. I’m going to be doing testing on machines that are a bit older (no pixel-shader support, slower clock speed, etc) so performance is a bit more critical.

    Another bottleneck with this that isn’t as much physics related is rendering. So while FPS give a good indication of performance it doesn’t give you the ultimate cause of why things are performing badly. XNA I believe has an advantage here as rendering wise it simply renders the demos faster than Blitzmax.

    My original motivation behind making this port is to create a game of my own in Blitzmax. I wouldn’t be doing it if I didn’t think it’d enable me to create dynamic and fun games. So in short, Yes when finished I don’t see why it wouldn’t be capable of creating games similar to the above.

    As for the license, I believe this would qualify as a ‘derivative’ work of Farseer and would fall under the Microsoft-Permissive License or something compatible with it. Which to my understanding, is pretty loose and has minimal strings attached. more info here: http://www.codeplex.com/FarseerPhysics/license

  3. Yes indeed Brucey is working on the very last version of Box2d since there is a SVN repository. I speak about Box2d because I thing I read somewhere at Farseer game that Farseer was based on the work of Erin Catto.

    I didn’t notice at first that Farseer don’t have any CCD. Hope this won’t be an issue with bullet type element.

    Effectively the impression of “slowliness” surely came by the way of blitzMax render things.
    Well I suppose a difference of 1~5ms is better than nothing ๐Ÿ™‚ Hope it’s not too CPU consuming.

    You working since a long time on this complete revamp ?
    I suppose we only be able to play with Farseer when you decide it’s features complete and optimized for the best performance.

    Would it be possible to write a tiny example with a faster time step like for a normal game. I like physics engines but always find examples playing too slow and not realistically (maybe to prevent inaccuracy ?)

    Maybe both physics engines (box2D and Farseer) will come at the same time so we could compare them and see which one is the more suitable.


  4. Do you have any idea when u will be releasing this engine port? i was going to use it on C# but im not too good at it but Blitz is alot easier… Does this also work with blitz3d? im sure it will becaus eit uses the same commands mostly

  5. @Arme
    Yes, that is right. Farseer was based on an earlier version of Box2D. Farseer right now doesn’t have any support for CCD and not really sure on Jeff’s plans to implement that, if at all. From my tests, it’s been pretty solid in terms of catching fast collisions. It really would come down to how ‘fast’ your bullets are traveling per frame and tweaking it to within Farseer’s capabilities.

    Also keep in mind the ~1-5ms differences are coming when LOTS of objects and activity are going on at the same time (stress tests). During normal use of Farseer BMX there is virtually no performance difference.

    I’ve been working on this port for 80+ hours. Still some hours to go as I implement that last few springs/joints/controllers along with demos to test their functionality. Once everything is ported and working I’ll make an initial release for others to play around with, maybe even get it working on mac/linux.

    I’ll keep that in mind for the future demos I develop to make a faster time step. So far I haven’t had much issue using a faster time step with the engine.

    FarseerBMX in no way is ‘competing’ against Box2D. I hope to release this to the community to give users of Blitzmax more choices when it comes to physics engines. Right now there is Chipmunk, soon to be Box2D, and soon Farseer. Each has its own advantages/disadvantages. Farseer has concave collision support, and Box2D has Continuous Collision Detection. Which ever is more important to the developer they can decide. Who knows, maybe in the future both features will be present in either engine?

  6. @ Leonard
    I can’t give any definitive dates right now. All I can say is I’m working as much as possible to finish this port on top of other responsibilities and projects. This engine does not work with Blitz3D. The engine is very object-oriented, and from my understanding Blitz3D is more procedural like previous blitz languages (Blitz, Blitz+), so converting to Blitz3D wouldn’t be trivial.

  7. Thanks for the answers Alex ๐Ÿ™‚

    Absolutely, FarseerBMX, Chipmunk and Box2D are different and not ‘competing’ against ^^

    Choosing between theses 3 physics engines will be a nice contribution to blitzmax !

    I’m wondering if concave bloc could be use as deformable terrain ? Does the polygons definition of objects in Farseer can be dynamically modified ?

    Also it’s probably the most CPU consuming type of collision to process. Is the number of maximum ‘vertex’ point is important in term of performance ?

    Digging holes in the ground will create a huge amount of these vertex, maybe it’s not the best approach ?

    I will ask the same question to Jeff since he probably know the answer ๐Ÿ™‚

  8. Well, Thanks for the info… Guess i better try and get Blitzmax then lol, What sort of commands does the engine use to make a static 2D object, into a phycics enabled one? As there are some engines that seem to be using very simple commands to achieve this…

  9. The API was designed to be easy and straightforward for creating physics objects, but still maintains a lot of flexibility. Once I’ve finished the port I plan to do some documentation that the demos might not convey as easily.

  10. Documentation would be very helpfull… Im currently using ppIsaac which is quite annoying when they dont give proper examples.

Leave a Reply

Your email address will not be published. Required fields are marked *