Wednesday, 16 January 2013

Doing it properly

The trouble with spaghetti code is that it's too rigid to comfortably fit in a different box to its original. Surrounded was mostly working nicely, but there were missing pieces of user interface (mostly monster health), nasty bugs associated with victory/defeat, and a general inability to add all the cool new features I wanted to.

So, refactoring. I started that by attempting to write a basic GUI menu system in raw SFML. Bad idea. After deciding to use a library, and eliminating GWEN, libRocket, SFGUI, and a few others, I settled on CEGUI. Bad idea.

CEGUI was the only usable thing left though, so I struggled through it and managed to get a menu system with a decent look and feel running. The CEGUI standard skin, Taharez, is very complete and looks good, except for the default cursor which is insupportable. Luckily I managed to find GlossySerpent, which looks like a homage to Warcraft III and has an acceptable cursor. Not ideal considering the more sci-fi-like angle I took when figuring out a setting for the game, but it'll do for now.

Yes, Surrounded has a setting and a plot now. It was quite difficult to figure out a world where such Schoenbergian game mechanics would make sense, but somehow it only took a day to figure out.

Anyway, I can now define menus quite nicely in XML using CEGUI's GridLayoutContainers to avoid specifying exact locations (but calculating the margins takes some effort). That means I can actually start focussing on transferring in the game code - the 96% of the work which will probably take 20% of the effort.

Yes, I've been drinking the optimist kool-aid.

No comments:

Post a Comment