Qbasicnews.com
November 19, 2019, 10:47:14 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: SDL and Key Trapping  (Read 2984 times)
Nathan1993
Member
*
Posts: 83


« on: February 08, 2005, 05:48:05 PM »

please, point me to where I can learn key trapping and sdl. if you want me to look at code please comment it! :lol:
Logged

f a fly walked, would it be called a walk?
Why dosn't someone make a word that rymes with purple or orange?
WHY AM I SO ANNOYING? Becuase I wanna!
Why am I typeing this? Cuz im bored!
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #1 on: February 08, 2005, 06:14:08 PM »

This is the best source I know about SDL: http://sdldoc.csn.ul.ie/index.php Wink

and, of course, http://www.libsdl.org/tutorials.php
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
BastetFurry
Forum Regular
**
Posts: 136



WWW
« Reply #2 on: February 08, 2005, 07:37:08 PM »

This goes as follow:

Code:

dim keys as uint8 ptr  
keys = SDL_GetKeyState(NULL)

if keys[SDLK_UP] then
  ' Do something
endif
if keys[SDLK_DOWN] then
  ' Do something
endif
if keys[SDLK_LEFT] then
  ' Do something
endif
if keys[SDLK_RIGHT] then
  ' Do something
endif

Problem here is that you cannot do it with a nice looking select but have to use ifs as keys is an array of 255 elements.

If you need to know what SDLK_Something you need have a look at SDL_keysym.bi

Have fun ^.^

EDIT: If you just want to check it when a key is actauly pressed, check your event holder for SDL_KEYDOWN

(Just copied my simple keywait routine)
Code:

sub SDL_WaitForKeypress()
   dim WaitForKeyEvent as SDL_Event
   do
   SDL_PollEvent(@WaitForKeyEvent)
   
   select case WaitForKeyEvent.type
      case SDL_KEYDOWN:
         'Do your key stuff here!
         exit do
      case SDL_MOUSEDOWN:
         'Do your mouse stuff here
         exit do
   end select

   loop
end sub
Logged

color=red]Look at you, Hacker. A pathetic creature of meat and bone, panting and sweating as you run through my corridors. How can you challenge a perfect, immortal machine?" - Shodan, AI at Citadel Station orbiting Earth[/color]
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!