This post is going to be extremely boring to everyone who’s not me, but I wanted to quickly express pleasure with a bit of VectorStorm restructuring I’ve been doing today. So apologies to everyone in advance for the technical code discussion that follows. Feel free to ignore the remainder of this post, and I’ll talk more about game design issues tomorrow. ;)
I’ve been extremely unhappy with the Box2D integration into VectorStorm ever since I started it, but hadn’t really been able to figure out how to fix it. I always ended up with Box2D-specific code in game code, which effectively ties individual games directly to the Box2D game engine, but I’ve finally figured out how to encapsulate Box2D (or any other physics engine) into an abstraction layer.
Just like VectorStorm isolates the OpenGL rendering from game code via the vsDisplayList class, so too does it now isolate Box2D from game code via the colObject class (todo: possibly rename this class). This still needs a lot more work; in particular, joints still require implementation within the translation layer. But moving in this direction makes me much happier, since it gives VectorStorm more flexibility. That is, in the same way that we could switch to DirectX or any other rendering framework merely by modifying one or two source files, we could just as easily switch to APE or another physics engine simply by modifying one or two files, without ever needing to touch the dozens or hundreds of files of game code.
And of course, the fewer places where I need to convert vsVector2Ds into b2Vec2s and back, the better. ;)