KeyPress Problem
Okay, so Im a noob, and figure I would start out with a simple pong game. No problem doing the graphics really, but, I am having a problem with Key Press issues. I have if WM_KEYDOWN to check which keys people are pressing to decide which way to move the paddle, but, I find, in two player, if one person is holding down a key, the key the other person is holding down won''t work. How should I fix this problem?
-Jason
the eaay way is that you could use an array of bools, and set the ines that are down to true, the hard way IMHO is learn direct input. I like easy things, so i'll give ya some code to that effect
ie (taken from NeHe tutorials but not specific to OpenGL)
edit: Note that in my experiance this can only handle about 4 or 5 keys at one time... and it depends on which keys... i think that has something to do with the way keyboards send data... i'm not realy sure.
-------------------------------------------------
Don't take life too seriously, you''ll never get out of it alive. -Bugs Bunny
Edited by - Authustian on November 2, 2001 9:31:23 PM
ie (taken from NeHe tutorials but not specific to OpenGL)
bool keys[256]; Array to hold all the keys we've got and add this to your WndProc Callback case WM_KEYDOWN: // Is A Key Being Held Down?{ keys[wParam] = TRUE; // If So, Mark It As TRUE return 0; // Jump Back}case WM_KEYUP: // Has A Key Been Released?{ keys[wParam] = FALSE; // If So, Mark It As FALSE return 0; // Jump Back}
edit: Note that in my experiance this can only handle about 4 or 5 keys at one time... and it depends on which keys... i think that has something to do with the way keyboards send data... i'm not realy sure.
-------------------------------------------------
Don't take life too seriously, you''ll never get out of it alive. -Bugs Bunny
Edited by - Authustian on November 2, 2001 9:31:23 PM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement