From: sdl-admin@libsdl.org [mailto:sdl-admin at libsdl.org]On Behalf Of
Alan Wolfe
Sent: quinta-feira, 29 de janeiro de 2004 15:24
To: sdl at libsdl.org
Subject: Re: [SDL] No key pressed
instead of making it a global variable, you could make it a variable within
main.
not sure how global variables go against OOP design but whatever.
you could also have done it this way (this is pseudo code)
if up key is pressed
increase velocity
else
decrease velocity
instead of like this
if up key is pressed
increase velocity
decrease velocity
glad you got it to work though
----- Original Message -----
From: @Bruce_Barrera (Bruce Barrera)
To:
Sent: Thursday, January 29, 2004 5:17 AM
Subject: RE: [SDL] No key pressed
My app is a girl running in a tunnel…when no keys are pressed, the
velocity of the girl must be slowing down.
If the user is not pressing the SDLK_UP, then no velocity is being charged
to the girl and then she must stop!
Thats why I need to know if no keys are being pressed.
The way i solved my problem was not checking for keys but each frame, if a
SDLK_UP is being pressed, I increase
her velocity by 0.005 and always decrease by 0.002
Then if user is not pressing SDLK_UP, the velocity will be descrease by
0.002 until her stop. This way I assure that
she will stop if no keys are being pressed.
Well, I saw that the only way to know if no key was pressed is scanning the
array of keys. Well, this is not the way I
would like to do, but I think that scanning a 256 positions array will not
be so costly, will it?
I dont want to make global variables since my app is all Object Oriented and
such.
Thnxs for everyones reply,
Cheers,
Bruce
-----Original Message-----
From: sdl-admin@libsdl.org [mailto:sdl-admin at libsdl.org]On Behalf Of
Matt Wilson
Sent: quarta-feira, 28 de janeiro de 2004 23:30
To: sdl at libsdl.org
Subject: Re: [SDL] No key pressed
On Wed, 2004-01-28 at 21:19, Bruce @ OpenGL wrote:
Hi folks,
To see which key was pressed, I use SDL_GetKeyState in this way:
Uint8* keys;
keys = SDL_GetKeyState(NULL);
then I check here:
if (keys[SDLK_UP])
{ do something; }
But and if I want to check if no key was pressed, after a call to
SDL_GetKeyState ???
I’m curious what sort of system would need to know explicitly when no
keys are pressed? Surely most systems only perform explicit actions when
keys are pressed, not when they’re not?
Thnxs,
Bruce Christopher Barrera
Moderador da lista de discuss?o OpenGL_Brasil
http://br.groups.yahoo.com/group/opengl_brasil/
Moderador da se??o OpenGL do F?rum do PDJ Brasil
http://www.pdj.com.br/forum
“Existem 10 tipos de pessoas. As que entendem binario e as que nao
entendem…”
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl
–
http://www.mattsscripts.co.uk/
- A great source for free CGI and stuff
Logic doesn’t apply to the real world.
– Marvin Minsky
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl