Ahh, Inexorable Progress

chromatic on 2004-02-06T07:00:40

(Yes, I am aware of the synonym inflexible.)

After two more bits of hacking, events work with SDL Parrot. That is to say, I can move the little parrot logo around on screen by pressing and releasing the cursor keys. I can even shut down the program cleanly by pressing Escape.

Okay, so it's a little grotty and not documented. (You'd be impressed by the rest of the documentation, however.) True, I can only detect five keys (up, down, left, right, and Escape) and I make no distinction between key up and key down events. Of course, two hours ago, I could barely report a key detection. This is progress.

There are two ways to detecting keyboard events. One is to pass a list of events and callbacks to a loop. The other is to process incoming events and run through the state machine yourself. Since I like first-class functions so much, I went with the callback approach.

Since I'm writing examples at the same time, the necessary abstractions are beginning to appear. It may be time to delve into PIR object syntax. I'll have something really cool to show off by the time OSCON rolls around.