Geek-o-Philiac

Monday, September 11, 2006

The Duelist: Continued

I posted a post-mortem for The Duelist not 24 hours before they extended the deadline. I'm not too happy about this, not because I prematurely posted a post-mortem, but because I'm ready to be done with this game. I have other things I want to focus on (XNA, Parodica, David Baraff's papers on physically based modeling, Half-Life 2 modding, C#), but I can't just sit idly and not do anything with an entire week. So, yet again, XNA & Parodica updates are put on temporary hold until (hopefully) the end of the week.

But this did cause me to think of an area where event passing clearly wins over input polling. The dance pads didn't arrive until late - over a full week into the competition for me and longer for others. Thus, I found it necessary to begin development without the pads. As I mentioned in my post-mortem, this was good because it allowed me to get a head start and also made debugging a great deal faster.

When the pad arrived, I needed to integrate it quickly. Had I used polling I would've needed to find every instance where I polled for input and retro-fitted it to poll for and handle joystick input as well. Not only tedious, but error prone and code-uglifying. But since I was using event management, I needed to make a change in one place - I simply incorporated a 'joystick translator' that took joystick inputs, converted them to the appropriate keyboard characters I was already using for input, and then sent that through the event system as though they were keyboard events. It was clean, it was elegant, and it was easy.

Ideally, it's not the most elegant solution. Since my code is bound to the keyboard keys, it makes remapping keys (to user preferences) difficult. A better route would have been to translate both keyboard keys and joystick input into a common 'game action' type of event, which could easily be remapped as the user wanted. But my solution works well enough for these purposes.

0 Comments:

Post a Comment

<< Home