Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: keyboard question.

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2005
    Posts
    4

    keyboard question.

    I've created a 3-d maze program that's heavily based off of the maze example on the SGI website( download here ), 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

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jul 2001
    Location
    France
    Posts
    1,749

    Re: keyboard question.

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •