PDA

View Full Version : Keyboardfunc



Vischnu
06-06-2009, 03:47 PM
Hi guys,

im a few month into opengl now and im working on a small 2 player game. the first player moves with awsd, the 2nd with ijkl
and im using the glutkeyboardfunc().
my problem is now that it isnt possible to press 2 buttons simultaneous. so at the moment, if you move, and the other player presses a button you get interrupted.
how can i make it possible that both players have full controll and dont get interuppted by the other?

any ideas to solve that problem?

big thx for your help!

ZbuffeR
06-06-2009, 04:20 PM
Use GLFW instead of GLUT. Really.

marek-knows.com
06-07-2009, 09:00 AM
Avoid using GLUT if you are going to be making a game.

I'm working on Windows so I use the Win32 message pump directly to get all the key presses. You have a lot more control this way.

Optik
06-07-2009, 11:44 AM
You might try Or-ing the inputs into a single key-case and perform the appropriate operations on each player's entity separately.

this way it works no matter how many inputs simultaneously.

If you dont mind using win32 i would recommend it any day.

Vischnu
06-08-2009, 08:08 AM
You might try Or-ing the inputs into a single key-case and perform the appropriate operations on each player's entity separately.

this way it works no matter how many inputs simultaneously.


sry i dont understand...

here is a short preview of my keyboard method



void keyboard(unsigned char key, int x, int y){

switch (key) {

case ' ':
player1.shoot();
break;

case 'a':
player1.rotateY(+3);
break;

case 'd':
player1.rotateY(-3);
break;

//player 2
case '.':
player2.shoot();
break;

case 'h':
player2.rotateY(+3);
break;

case 'k':
player2.rotateY(-3);
break;


etc....
}
}



so how should i change that?

if there is no other way, i will try it with glfw. but im using many glut operations, so it will cost me much time to change all my already written code!