Monday, December 6, 2010

Debug Helpers

When you're developing a game, it can be very helpful to "see" what's going on with your objects.  Thus, in v2.0 I've been merging the debug helpers into the components directly.  When you enable engine debugging with Engine.setDebugMode(true), or use the debug=true query parameter, it will enable all of these debug helpers.  What they are, are things like bounding boxes or collision hulls for collider components, the origin axis for transformations, and image outlines for billboards.

These kinds of helpers just make it easier, at least on me, to verify that something is occurring and that it's occurring correctly.  For example, last night I was trying to figure out why some changes I made to the Asteroids demo were causing the objects to spin about an origin that didn't seem to be where I thought it was.  Enabling the debugging helped me to see that the origin had been moved and correct the issue.  Using debug mode increases the frame render time, since it has to draw these helpers, but it's only while debugging is enabled.  All of the helpers are in pragma:DEBUG blocks, so they won't be compiled into the production version of the engine.

There have been some changes to some of the components, including the Vector2DComponent.  I noticed that render components were setting the bounding box for their host object.  Originally I intended this to be the way render components worked, but I've realized that while this is nice to have, it can also be painful to debug.  Plus, when I changed the way bounding boxes are created (they now have a top-left origin of 0,0 and only a width and height) this broke because most vector-drawn objects have their origin at the center.  Transforming the origin would typically put it at the lower-right corner of the object box, so it was breaking all across the board.  As such, a vector component will calculate a bounding box that you can retrieve from it (and now a convex hull) but it becomes a manual process, rather than an automatic one.

Also, I got the abstracted SoundSystem working last night with the Sound Manager 2 system plug-in.  It was a nice feeling being able to plug-in and remove the sound system entirely, and still have the game function regardless.  Now I will start, in earnest, making the HTML5 system plug-in.

I suspect that when people try to migrate from versions of the engine, prior to v2.0, they will be a bit shocked.  I've been noting these changes in the release notes for v2.0 mainly because there are a lot of little things like this.  It's all in an effort to make the engine faster, more optimized, and cleaner.  The difference between the v1.5.3 engine and the v2.0 engine will be fairly dramatic.  But overall, I think people will be happier with it...  It's really grown up a lot.

No comments:

Post a Comment