Jump to content

  • Log In with Google      Sign In   
  • Create Account


Glut and key input.


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 laeuchli   Members   -  Reputation: 336

Like
Likes
Like

Posted 08 October 2001 - 07:54 AM

Hey, I''m writing a game(www.laeuchli.com/jesse/), where you fly a spaceship around and shoot. I''m using GLUT and OpenGL. The problem is, that I can''t press more then one button at a time. For example, the down arrow pulls the plane up, and the right arrow makes the plane go right, and they both work sepratly, but when I try to do both at once, only one takes. This is annoying, and I need to find a way to fix it. How should I do it with glut? Thanks, Jesse www.laeuchli.com/jesse/

Sponsor:

#2 Bad Monkey   Members   -  Reputation: 145

Like
Likes
Like

Posted 08 October 2001 - 03:39 PM

One way you could do it is have an array of booleans (one for each key) eg declared like this:

bool keyDown[NUM_KEYS];

... and when a key is pressed, set its keyDown to be true (and inversely, when a key is released, set it to false).

Then, somewhere else (perhaps in an idle func or timer func), you check what keys are down at that given moment, and move your ship accordingly.

Simple, eh?


EDIT: you may also want to suppress key repeats (no point processing multiple keydown events)... but i can't remember how to do it off the top of my head... check the glut docs

Edited by - Bad Monkey on October 8, 2001 10:42:31 PM


EDIT (again): I just checked the docs myself, and it seems that my rusty memory has failed me again... there doesn't seem to be a way to determine when a key is released (only pressed). Must've been thinking about mouse buttons ...sorry about that

Edited by - Bad Monkey on October 9, 2001 9:40:51 AM

#3 Vlion   Members   -  Reputation: 151

Like
Likes
Like

Posted 08 October 2001 - 06:19 PM

Hey wow thanks. I`ve been wondering about that myself.
I havnt done any work with it though, so thanks.
~V''lion

I came, I saw, I got programmers block.
~V''''lion




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS