PDA

View Full Version : More than 1 key held down



03-29-2002, 11:17 PM
Hello,
When I hold down a key to move around an object, it jerks for a bit then moves constantly. However, if I then press another key down it ceases all movement. I'm making a simple 2 player aracde game in GLUT and this is a major flaw, with there being two players :P

Any help greatly appreciated.

chowe6685
03-30-2002, 07:03 AM
goto nehe.gamedev.net and look at the basecode he uses. The lessons are in Win32 (though you can download glut source), but the idea of using an array of bools works quite well

Morglum
03-30-2002, 11:57 AM
Use GetAsyncKeyState (defined in winuser.h).
That's not the only way, but the simplest in my opinion. You can also use GLUT to maintain an array of bools (1 per key) - this has been covered in some recent threads.

Hope this helps
Morglum

marcus256
04-01-2002, 10:50 PM
GLFW (http://hem.passagen.se/opengl/glfw/) does this automatically for you. The glfwGetKey() function checks the value of a key-code array, which maintains up-to-date key states. There is also an example of a simple two-player game included with the GLFW distribution that uses the keyboard for input.