Results 1 to 5 of 5

Thread: Keyboardfunc

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2009
    Posts
    2

    Keyboardfunc

    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!

  2. #2
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: Keyboardfunc

    Use GLFW instead of GLUT. Really.

  3. #3
    Junior Member Newbie marek-knows.com's Avatar
    Join Date
    Jun 2009
    Location
    Waterloo, On, Canada
    Posts
    19

    Re: Keyboardfunc

    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.
    Free OpenGL & Game Programming video tutorials:
    www.MarekKnows.com

  4. #4
    Junior Member Newbie Optik's Avatar
    Join Date
    Jun 2009
    Location
    Los Angeles, CA
    Posts
    22

    Re: Keyboardfunc

    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.

  5. #5
    Junior Member Newbie
    Join Date
    Jun 2009
    Posts
    2

    Re: Keyboardfunc

    Quote Originally Posted by Optik
    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
    Code :
     
    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!



Similar Threads

  1. keyboardfunc()
    By imported_GMan in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 03-27-2006, 02:12 PM
  2. KeyboardFunc not working as desired
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 10-14-2005, 05:04 AM
  3. GLUT KeyboardFunc - Crash problems.
    By kvinther in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 06-07-2003, 02:48 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean