Tomorrow marks the beginning of Global Game Jam 2010, which means I’ll take a brief respite from Postal Worker development. Expect the 13th installation to be late in the week next week.
Tonight I started by implementing a pause mode in KranzkyEngine. You can now pause, resume and stop it. Pause is pretty straightforward to implement; the engine sets or clears a boolean flag, and passes a time delta of 0 to all update methods if it is paused. It worked without issues in the HelloKranzky sample game.
Of course, once the pause mode was in, I wanted to tap to pause and tap again to unpause. Sure, this could be hacked in quickly, but the whole point of this exercise is to build a neat, re-usable game engine, so I took the lengthier route. I realised that I want at least four “managers” in the game engine:
- The ContextManager, which you’ve met before
- An InputManager, to take player input (keyboard, multitouch), appropriately transformed
- An EntityManager, to handle all of the game objects, and
- A SystemsManager, to handle various systems (like Physics), where each System is responsible for all of the Components that may be attached to Entities
So I began by refactoring the ContextManager to derive from a KranzkyManager ABC, and then I added addManager and getManager calls to the Engine. Internally, the Engine iterates over the list of managers, calling update() and render() on each one.
The cool thing about this is that a game could, conceivably, add a new manager to the engine without touching any engine code. Which is awesome.
Anyway, by the end of the night I had the sample game running, identically to before, using the new system. And I didn’t have any time to implement the InputManager that started this whole thing off. That’ll be for next week :)