PDA

View Full Version : keyboard question.



akya
10-17-2005, 08:32 AM
I've created a 3-d maze program that's heavily based off of the maze example on the SGI website( download here (http://www.sgi.com/products/software/opengl/examples/more_samples/zip/maze.zip) ), only rewritten using console/glut functions instead of Win32 functions.

the program has some floats that control movement these include:
player_s-controls speed of movement(backward(float is negative) or forward(float is positive))
and
player_t-controls speed of turning movement(negative is counter-clockwise, positive is clockwise)

I'd like to have it so it's like a typical 3-d game(ie wolfenstein) where you must hold a button in to walk forward/turn/move

right now i have the w key incrementing speed, s key decrementing it, left incrementing turn speed, and right decrementing turn speed.

i'm sure someone can tell me how this works. basically i need the speed to change while the key is being held, then reset to zero once the key is released

jide
10-17-2005, 12:04 PM
Well this is just programming stuff, thus this has nothing to do with gl.

You can store the state of the keys so that you can know if a key is actually down or just release or so. If a key is pressed then accelerate, if at the next tick it is still pressed then modify the acceleration, if it is released, then decelerate.