Sunday 18 October 2009

Lara, I Love You!

Recently I had another song broadcast on One Life Left, a radio show about videogames. In fact, an award winning radio show about videogames! I reckon it was my songs what won it!!!

The recent effort was actually a collaboration (something which to my great discredit I failed to inform the OLL team of, so my collaborator was uncredited!). We'd hoped he'd supply guitars to beef up the sound (with a solo verse, no less!), but it wasn't to be. Still, he supplied a couple of gag ideas and maybe a rhyme or two, so he should have received some of the limelight! Sorry ...

Anyway, it's an ode to Lara from an admirer. Enjoy!



Tuesday 6 October 2009

Tweakables

I've been busy recently with XNA stuff, trying to get a nice physics model of a vehicle going. You soon discover that you accumulate a huge number of "settings" - constants that affect the behavior of your model. Tweaking these to get the best values you can (or maybe different styles of behavior for different "makes" of vehicle), can be a bit of a pain, restarting every time you want to make a tiny change and test it.

Imagine my delight then when I read this article by awesome XNA blogger Sean Hargreaves about "Tweakables" - the idea that you set up these constants so that you can adjust them on the fly, while the game is running. I knew I had to implement this - it's just too useful not too! (See Sean's next article for other potential uses).

I looked at Sean's suggestions for how to implement this in XNA ... but of course, I thought I had a better idea.

So I created a custom attribute, "Tweakable" (of course!), which I added to some of my static properties (which were simple, lazily coded public member variables until then). Then I created a form which iterates through all the types in my game's assembly, and for any "Tweakable" properties it finds, it adds corresponding controls onto the form (some work here to give them nice labels, organise into a tab per type, etc etc). Finally, an event handler is dynamically added to the controls so that the property is updated when the control is "left".

Et voila - when my game loads I also get a form for adjusting all the "tweakable" properties I like!

I intend to implement the ability to save all the current settings to file, and load them again, plus to start with an initial set. This way, I can save settings I like or which are useful for debugging, and I can exchange settings the rest of my "team" (there are three of us working on something together). I also need to expand the types of variables supported (admittedly just floats so far - will certainly need Vector3's which may require a custom control ...).