Need HELP w/ VB Keyboard Input (multiple keypress)
I am working on a two-player, split screen game that is very keyboard intensive. Both players control their respective character via keyboard input. The character control is very fluid, but requires that the user hold down two or more keys (such as the ''up'' AND ''left'' keys to move in a diagonal direction. The problem is, I can not get the program to register more than three simultaneous keypresses. If player one is moving diagonally, then player two can only move up, down, left, or right as the fourth keypress does not register. If player one moves diagonally AND fires guns then player two cannot move at all! I am currently using the GetAsyncKeyState() API function inside of a do...while game loop. The players each have their own small form, which are child forms in an MDI. Please, please help as the game is complete except for this control issue. It pains me to not be able to share my game w/ family and friends because of this one little issue! I thank you in advance for your time and consideration on this problem!
thomas
sebek12345@aol.com
www.neurosy.com
www.neurosy.com
You should try using a table instead of using GetAsyncKeyState().
Like this:
byte KBStatus[256]; // 256 virtual keys
GetKeyboardState(KBStatus); // get the state of the keyboard
Now the status of all keys are in the table.
Of course, the routine of getting the keyboard state will be in a loop.
Or, maybe with one of the keyboard messages:
...
case WM_KEYDOWN:
// get keyboard status
// check what was pressed
- Goblineye Entertainment
The road to success is always under construction
Edited by - Tornado on June 14, 2001 8:18:50 AM
Like this:
byte KBStatus[256]; // 256 virtual keys
GetKeyboardState(KBStatus); // get the state of the keyboard
Now the status of all keys are in the table.
Of course, the routine of getting the keyboard state will be in a loop.
Or, maybe with one of the keyboard messages:
...
case WM_KEYDOWN:
// get keyboard status
// check what was pressed
- Goblineye Entertainment
The road to success is always under construction
Edited by - Tornado on June 14, 2001 8:18:50 AM
Goblineye EntertainmentThe road to success is always under construction
Tornado,
Thank you VERY much for your reply. I have tried the GetKeyBoardState() API early on in the games development and I seemed to run into the same keypress limitation. It is, nonetheless, a most excellent suggestion and I will most certainly look into it again. After reading your reply and refreshing my memory on the GetKeyboardState() function I am convinced that, if nothing else, it is a superior approach to the GetAsyncKeyState() call.
BTW, a most interesting site you have there. Anybody reading this, do yourself a favor and CHECK OUT TORNADO''S WEBSITE (listed in the reply above this one). The examples there definately push the envelope on VB game design. You will find yourself asking "can that really be done in VB?" Seriously, have a look!
Thanx Tornado!
Thank you VERY much for your reply. I have tried the GetKeyBoardState() API early on in the games development and I seemed to run into the same keypress limitation. It is, nonetheless, a most excellent suggestion and I will most certainly look into it again. After reading your reply and refreshing my memory on the GetKeyboardState() function I am convinced that, if nothing else, it is a superior approach to the GetAsyncKeyState() call.
BTW, a most interesting site you have there. Anybody reading this, do yourself a favor and CHECK OUT TORNADO''S WEBSITE (listed in the reply above this one). The examples there definately push the envelope on VB game design. You will find yourself asking "can that really be done in VB?" Seriously, have a look!
Thanx Tornado!
www.neurosy.com
You''re welcome ![](smile.gif)
Goodluck with your game!
- Goblineye Entertainment
The road to success is always under construction
![](smile.gif)
Goodluck with your game!
- Goblineye Entertainment
The road to success is always under construction
Goblineye EntertainmentThe road to success is always under construction
Tornado,
When you finish some of those games, look me up - I''m starting a website for programmers to distribute their games online - (www.neurosy.com). BTW, did you run into any of these issues in your 2 player deathmatch game? If so, did you solve them using the method you described above or did you go with DirectX (direct input)? I haven''t had a chance to look at the deathmatch game because my laptop doesn''t support DX and the direct draw fails. Thanx again, Tornado.
www.neurosy.com
When you finish some of those games, look me up - I''m starting a website for programmers to distribute their games online - (www.neurosy.com). BTW, did you run into any of these issues in your 2 player deathmatch game? If so, did you solve them using the method you described above or did you go with DirectX (direct input)? I haven''t had a chance to look at the deathmatch game because my laptop doesn''t support DX and the direct draw fails. Thanx again, Tornado.
www.neurosy.com
www.neurosy.com
No, Actually, the 2 players deathmatch game (Rupin Deathmatch) isn''t my game, Xeno wrote it himself some time ago.
I asked him about the input techinque he used, he says he used GetAsyncKeyState() in a while loop just like you did. He didn''t have any problems with it though.
Nonetheless, I still suggest you use the table thingy
It''s a neater way in my opinion.
- Goblineye Entertainment
The road to success is always under construction
I asked him about the input techinque he used, he says he used GetAsyncKeyState() in a while loop just like you did. He didn''t have any problems with it though.
Nonetheless, I still suggest you use the table thingy
![](wink.gif)
- Goblineye Entertainment
The road to success is always under construction
Goblineye EntertainmentThe road to success is always under construction
Tornado,
I still agree with your GetKeyboardState() premise. I will try to implement it this weekend. BTW, deathmatch has the same problem on my computer. You can only hold down three keys at a time. I wonder if this problem is hardware specific. In deathmatch the contol is different insofar as holding down two of the directional keys causes the character to run in circles, whereas in my game it causes diagonal movement - so this issue may have just never come up in the development of deathmatch. You mightlet Xeno know regardless, and tell him about your buffer/array idea as well...
Thanx again, Tornado. I have a feeling the array thing will work. Crossing my fingers...
I''ll update as to my progress here soon...
Have a good one.
I still agree with your GetKeyboardState() premise. I will try to implement it this weekend. BTW, deathmatch has the same problem on my computer. You can only hold down three keys at a time. I wonder if this problem is hardware specific. In deathmatch the contol is different insofar as holding down two of the directional keys causes the character to run in circles, whereas in my game it causes diagonal movement - so this issue may have just never come up in the development of deathmatch. You mightlet Xeno know regardless, and tell him about your buffer/array idea as well...
Thanx again, Tornado. I have a feeling the array thing will work. Crossing my fingers...
I''ll update as to my progress here soon...
Have a good one.
I''m pretty sure it''ll work ![](smile.gif)
Xeno already knows about using a buffer, but I doubt he''ll want to make changes in the game since he stopped working on it some time ago.
Goodluck again!
- Goblineye Entertainment
The road to success is always under construction
![](smile.gif)
Xeno already knows about using a buffer, but I doubt he''ll want to make changes in the game since he stopped working on it some time ago.
Goodluck again!
- Goblineye Entertainment
The road to success is always under construction
Goblineye EntertainmentThe road to success is always under construction
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement