Thursday, May 7, 2009

Framework V2

Just finished adding some shine to my development framework. You can demo version 2 right here!

For those just joining us, this is just a basic shell of a game that incorporates many Box2D and interface elements. Features are:
  • Magic-number-free Box2D world generation. Just flag your SWF with the recommended dimensions and a scaling factor and the rest is done automagically.
  • Full camera controls, including zoom and pan, completely independant of the game world.
  • A Box2D Collision listener class with sample code for measuring load bearing
  • A GameMechanics class that adds objects, tracks health, and destroys objects when they get hurt (and can add "rubble" or "shrapnel" in doing so)
  • A GameWorld class that lets you play with gravity and other physical effects
  • A player character class that has its own keyboard hooks and graphics modelling, with examples on how to update graphics every tick to match the Box2D world
  • A menu system, including flippable instruction pages, a play now button, and a sound mute button. The menu pauses the simulation and pops up overtop of the game without ruining game state.
  • Full music/sound/volume/playback controls, including server-streaming MP3 capability
  • Cookie storage and tracking of user data (including mute status)
  • Pause button
  • Demonstration code for singleton classes
  • Craploads of comments so even Box2D/AS3 newbs can understand what's going on.
Unlike SpaceSquid, I'm trying really hard to get this code running quickly and done right. I'm hoping this framework will end up being the starting point for all of my future Box2D games, and as I learn new tricks I tack them on as modules for extensibility.

I still have some things to do - a server communication module and XML integration, a HUD module, and a few other odds and ends - but that shouldn't take too long, and it's in a very much usable state right now.

I'm still a bit posessive about all my hard work so I don't think I'll be giving it away just yet, but someday... Someday, I'll release the source and let the crowds go wild. I want to see more physics games and I think this is a good way to make it happen faster :)

4 comments:

  1. I was having fun turning off gravity and trying to push the big sticks up to the ceiling.

    ReplyDelete
  2. Negative gravity is quite amusing

    ReplyDelete
  3. Neat. One thing to be careful about is that you're building something out of one starting point (space squid). In geometric terms, if you have a single point, it's hard to nail things down. If you have two points, you can form a line. Three points, a plane. It's a stretch but if you apply this to programming, be careful with putting a lot of effort into a framework after one game. You are building around a single point, which often leads to the equivalent of a “sphere”.

    That sphere in game design abstract space becomes easier to develop in, which means your future game designs are drawn towards it. At the same time, any game design that doesn't fit into the framework becomes more expensive, because you've paid the cost for the framework but aren't benefitting from it.

    In the extreme, trying to “do things right” the second time leads to the second system effect: http://en.wikipedia.org/wiki/Second-system_effect . So be careful!

    ReplyDelete
  4. Hm, thanks for the heads up on the Second System Effect. It was an interesting stroll through Wikipedia for a few hours this morning. :)

    I've been pretty guarded in my development - I do have a goal in mind (Game #2) and I am somewhat developing all the tools to reference it.

    At the same time, any particular tool that would probably only benefit that game (such as writing a Box2D Explosion class) I've been refraining from writing... Despite it sounding like a lot of fun.

    One of the big problems with SpaceSquid was that I had laid out the internal structure incorrectly, and when I added a menu system very late in the game - then a secondary menu system on top of it (instead of underneath it, if that makes sense) - it became a convoluted mess. Woe to the person who looks at the source code.

    So - right now - the primary engine I've written can handle music, sound, keyboard/mouse inputs, contains a menu and a gameworld... Which are all very generic and should suit any game.

    The Box2D stuff - there isn't a lot of my code in there, but it's all very short - quick examples of how to implement something such as boundary listeners. Each of those little components is quite small in size and easy to exclude.

    In summary, I think I'm safe for now. :) I'll be sure to be a bit more wary of what it could become, though...

    ReplyDelete