Pressed keys problem

This is a discussion on Pressed keys problem within the Game Programming forums, part of the General Programming Boards category; For some reason, some combinations of keys can't be pressed at the same time. I'm trying to create a simple ...

  1. #1
    return 0;
    Join Date
    Jan 2005
    Location
    Netherlands
    Posts
    89

    Pressed keys problem

    For some reason, some combinations of keys can't be pressed at the same time. I'm trying to create a simple game, and these are the controls:

    LEFT: go left
    RIGHT: go right
    UP: jump
    SPACEBAR: shoot

    When pressing UP + LEFT, the character will move left while jumping. When pressing UP + SPACE, the character will jump and shoot at the same time. LEFT + SPACE will move the character left while shooting. However, when I press UP + LEFT + SPACE, the character will only move left while jumping. It doesn't shoot, but instead my computer will beep every second (the sound you get when you press too many keys at the same time). Is there a way too fix this? When I press UP + RIGHT + SPACE, everything works well (the character moves right while jumping and shooting)

    I check wether a key is pressed like this:

    Code:
    // Inside WndProc. keys is a global array (char keys[256])
            case WM_KEYDOWN:
                keys[wParam] = 1;
                return 0;
            case WM_KEYUP:
                keys[wParam] = 0;
                return 0;
    Code:
    // Inside function that checks keys and acts on them
        if(keys[VK_LEFT] == 1) {
            // Move left
        }
    
        if(keys[VK_RIGHT] == 1) {
            // Move right
        }
    
        if(keys[VK_UP] == 1) {
            // Jump
        }
    
        if(keys[VK_SPACE] == 1) {
            // Shoot
        }
    Last edited by Snip; 08-27-2005 at 10:01 AM.

  2. #2
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,803
    This is really a keyboard problem. There is nothing you can really do about except let the user map the keys for the controls.
    Woop?

  3. #3
    Registered User Kirdra's Avatar
    Join Date
    Aug 2002
    Posts
    105
    I had this problem using DirectInput, when I played my game on another computer it worked.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. REG_OPTION_BACKUP_RESTORE Problem
    By mercury529 in forum Windows Programming
    Replies: 2
    Last Post: 12-01-2005, 12:35 AM
  2. Replies: 5
    Last Post: 11-07-2005, 10:34 PM
  3. searching problem
    By DaMenge in forum C Programming
    Replies: 9
    Last Post: 09-12-2005, 01:04 AM
  4. half ADT (nested struct) problem...
    By CyC|OpS in forum C Programming
    Replies: 1
    Last Post: 10-26-2002, 08:37 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21