2008-10-04

Key Repeating, Timers and Bugs

First of all, a bug. The Text class doesn’t seem to be wrapping text properly if the line of text doesn’t have a break in it.

I hate the Text class. If anyone wants to earn themselves a substantial number of Zombie Points*, debugging and fixing the Text class will earn you a bucketload.

Secondly, key repeating now works in the keyboard. Instead of registering the keyboard for VBLs, I’ve written a WoopsiTimer class. This works in more or less exactly the same way as a Javascript timer. Give it a number of frames to count and tell it to start, and it’ll count that many frames and then fire an EVENT_ACTION event. It can be paused, stopped and reset, the timeout (frames until an event is fired) can be changed, and it can either fire once and stop or continually loop. It registers itself automatically for VBLs. In short, it’s a much better solution than the existing VBL system. It is far simpler to set up and considerably more helpful.

This leaves me with a question to resolve. Do I change the Woopsi class so that only timers can register themselves for VBLs or do I leave it as it is with two methods of achieving the same thing? The former results in a tidier API; the latter gives the developer more options (ie. it means they have one less child gadget to create). I’m leaning towards stripping the old method out, but I’ll leave it as it is for now in case I think of a good reason to leave it.

*Zombie Points are exchangeable for Zombie Tokens. 10 Zombie Points earns 1 Zombie Token. Zombie Tokens are exchangeable for Zombie Points. 10 Zombie Tokens earns 1 Zombie Point.