GLUT Keyboard problems

Started by
3 comments, last by dnaxx 18 years, 9 months ago
Hello, I want to navigate through my landscape with the up, down, left and right-keys. When I hold the up key pressed, I move forward. To move left, I press the left key and without leaving the up key. now I move one step left and then I stop. In games it is possible to go e.g. one step left while holding the up key and the going further without the need of repressing the up-key. I hope my description is understandable ;). How can this be achieved? Thanks,
Advertisement
Pretty similar to my problem I just posted.

http://www.gamedev.net/community/forums/topic.asp?topic_id=338511

I need to know this also :p

Thx
that's another issue but with a timing function, it should not be a problem.

regarding my problem: I fixed it with a array, which holds the values of pressed keys.
Can you please post how you did that?

I will want to move forward while say pressing strafe.

Thx
it's very simple.

bool pressed_keys[255];void init(){for (i=0; i<255; i++) pressed_keys = false;}void glutSpecialKeypressfunction(int key, x, y){pressed_keys[key] = true;}void glutSpecialKeypressUpfunction(int key, x, y){pressed_keys[key] = false;}glutRenderfunction(){if (pressed_keys[GLUT_UP_KEY]) moveforward;if (pressed_keys[GLUT_LEFT_KEY]) moveleft;...}


for the glutKeyboard function use (int)key instead of key (because key is a unsigned char.

that's it ;).

This topic is closed to new replies.

Advertisement