Physics

Screen Shot 2012-12-24 at 12.00.25 PMA few years back, on New Year’s Eve, Stephen “Increpare” Lavelle challenged me to create a game before the new year.  I had about eight hours to put something together  (I’d finished coding in time for the deadline, but arranging the Win32 version and setting up a download page took me a few minutes into the new year).  The result of that challenge is over here.

Well, he’s made that challenge again this year, albeit he’s given me a little more warning this time;  I have about eight days this time, instead of eight hours.  In order to put the game into my “Game in a Week” category, I’m not actually going to start thinking about what the game should be yet;  I’ll start on it tomorrow, which will give me a week to complete the game.

So today, instead of starting on the New Years’ game, I’m just going to do some prep work.

Last time, I realised that I had no way to do real 3D physics in VectorStorm (though the library is reasonably well integrated with Box2D for 2D physics), and so I kludged together my own simple collision system for that game based on the cursor selection code I wrote for MMORPG Tycoon 2.  It worked, but I couldn’t do anything other than kill the player, in response to hitting something.  This time, I’m going to be prepared in case I do want to make something that’s physics-enabled.  So today I’ve been working on adding support for the Bullet Physics library.  The image here is of a stacked pyramid of boxes, after I’ve fired another box through the middle.

This particular “firing a hole into a stacked pyramid of boxes” test is sort of the “Hello World” equivalent for physics libraries, these days.

Right now the integration between Bullet and VectorStorm is embedded in game code, not in VectorStorm itself.  Not sure whether I want to make Bullet be a VectorStorm requirement the way that SDL is, or whether it should remain something that individual games can provide for themselves.  Need to think it over a little.  Regardless, I do now have very simple physics support.  Rest of the day will be adding support for non-trivial shapes (ie: non-boxes), and I might test using joints between objects as well, just in case.