Thread: SDL multiple key presses...Help.

  1. #1
    Programming is fun, mkay?
    Join Date
    Oct 2001
    Posts
    490

    Question SDL multiple key presses...Help.

    Hello there. My current game project will be done is SDL using MS Visual C++ 6.0. I am integrating ASM into some of the code for faster speed. Anyhow, I was wondering if SDL can handle more than one key being pressed at a time. I was going to make the game a 2-player game, so I would like to know. If so, can I just do this:

    Code:
    if (event.key.keysym.sym == SDLK_LEFT) { 
        // Move player 1
        //
    
    }
    
    if (event.key.keysym.sym == SDLK_W) { 
        // Move player 2
        //
    
    }
    or does the second one need to be an "else if"?
    Website(s): http://www16.brinkster.com/trifaze/

    E-mail: [email protected]

    ---------------------------------
    C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
    DirectX Version: 9.0b
    DX SDK: DirectX 8.1 SDK

  2. #2
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    What you need is SDL_GetKeyState(). Look it up in the sdl docs @ libsdl.org (I'd have done it but the site appears to be down right now)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 11-23-2007, 01:48 PM
  2. Virtual keys
    By Arkanos in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2005, 10:00 AM
  3. Directional Keys - Useing in Console
    By RoD in forum C++ Programming
    Replies: 38
    Last Post: 10-06-2002, 04:42 PM
  4. FAQ: Directional Keys - Useing in Console
    By RoD in forum FAQ Board
    Replies: 38
    Last Post: 10-06-2002, 04:42 PM