[Plib-users] Don't Do This!
Brought to you by:
sjbaker
From: Steve B. <sjb...@ai...> - 2001-12-31 03:29:08
|
I'm not a happy person. :-( This is not so much a cry for help - as a warning for others in the future: I've been playing around with a multiplayer game (perhaps going in the direction of "Super Smash Bros'" on N64 and Game Cube). I've got to the point of dividing the screen into two, three or four chunks and rendering four cute little penguins - each of which can move independantly with a camera that follows along. I had all of it working with the controls for each player assigned from a config file (eg Player 1: MoveNorth = W, MoveSouth = Z, MoveEast = W, MoveWest = S Jump = Q, Fire = E Player 2: MoveNorth = I, MoveSouth = M, MoveEast = J, MoveWest = K Jump = U, Fire = O ...that kind of thing). So, if you are player 2, you hold down 'I' to move north, 'I' and 'J' together to move northwest. It all worked well in testing - but the first time my son and I tried to actually play together, we noticed that sometimes our keystrokes would be ignored. If player 1 moves NorthEast (holding down W and S) then the 'I' key (player 2's command to move North) wouldn't work. I puzzled about what might be wrong with my code - but eventually (after some questions to the LinuxGameDev mailing list and a bit of web surfing) discovered that this is a hardware limitation of the PC keyboard! Aaaaggghhhh!!!! I hadn't noticed it when testing because with just me pushing one or two keys, I never hit the combinations that cause problems. This suprised me a lot (which is why I'm writing this email - so that others don't fall into the same trap). The rule is approximately that if you hold down three keys that form the corners of a rectangle on the keyboards 'scan matrix' (E, C and I for example) then depending on the age of your keyboard, you'll either find that the third key you press will be ignored *or* the key at the fourth corner of that rectangle will appear to be pressed even though it isn't! I thought for a while about picking keys that didn't form the corners of such squares (eg E, C and G work at the same time) - but rapidly realised that I couldn't come up with anything remotely ergonomic in that way...not even for two players - let alone three or four! So now I have to rethink this in terms of two players using joysticks, one using the keyboard and another using the mouse. The trouble with that is that *very* few people have two joysticks and it's hard to make the controls fair when the players have different controllers. Grumble, grumble, grumble.... (If you want to try what I've written so far, you can grab it from: http://www.sjbaker.org/steve/tuxfighter.tgz ...the code is mostly from TuxAQFH - much cleaned up. Run it with "./src/tuxfighter -n 2" for two players, "-n 4" for four players, etc the control characters are displayed to stdout on startup and can be changed in data/players.dat - there is no way to use the numeric or arrow pads or function keys yet - but they have the same problems as the main keyboard). ----------------------------- Steve Baker ------------------------------- Mail : <sjb...@ai...> WorkMail: <sj...@li...> URLs : http://www.sjbaker.org http://plib.sf.net http://tuxaqfh.sf.net http://tuxkart.sf.net http://prettypoly.sf.net http://freeglut.sf.net http://toobular.sf.net http://lodestone.sf.net |