craftyjs/Crafty — pull request #484 by starwed (2013-06-09 04:37:49+00:00)
Title: Add a rendering layer for debugging

This PR does two major things:

* Refactors the drawing code so that instead of being a hard coded function call, the Canvas and DOM are drawn in response to a "RenderScene" event. This makes it possible to add additional rendering contexts more easily

* Adding another canvas element for drawing debug info onto, along with several components for common debugging tasks. An entity with the "DebugCanvas" component will receive a "DebugDraw" event, which it can use to draw to the debug canvas.
* I reworked "WiredHitBox" and "SolidHitBox" to use this new context.
* I added a "VisibleMBR" component for debugging MBR stuff. (This immediately let me find and solve a related bug!)

The one thing that the first point totally doesn't address is changes to the viewport. The current viewport code needs some attention, and when that happens viewport functionality can be added here as well.

I should probably add some tests, but since the functionality is basically done I thought I'd open this for people to comment on.