the problem is that keystate returns not the keys pressed at the moment,
but the keys pressed when SDL_Poll / Push /… Event was called.
i have a similar problem: in my tetris i have a delay of ~40 ms (worst
case) and if the player presses and releases a key during this time, the
key will show up as being not pressed in the keystate array
-> pollevent receives keydown, keyup, (otherevents) and fills keystate
with this info
my solution was to fill my own keystate array just with keydown messages
and set every key to up at the beginning of a frame. (i miss constantly
pressed keys in this way, but i don’t need them anyway).
i know you have a different problem, but maybe this helps.
peace, florian hufsky
Couannette wrote:
Why don’t you use the key state at the very moment your are asking its
status. I explain: when you enter your frame processing function, check
for UP/DOWN/LEFT/RIGHT at that moment, and not anywhere else in your
event loop. You’ll have proper response whatever your framerate is.On key statusk, here is the first pointer: Couannette Alejandro Santos wrote:
At what framerate do you keep your game ? Perhaps the problem is there.
Depending how do you get the input, if you read the events at each frame,
then if you are at a slow frame rate you will notice some lag.
For example: (in pseudocode)
while (run)
{
while(events_in_queue)
{
ReadInput
}
Draw
Delay //for constant framerate
}
If the Delay is too high, there will be a slowdown in the input processing.
I have never used Timers in SDL. Can you send how you did it ?
Byes.
Alejandro.
----- Original Message -----
From:
To:
Sent: Thursday, December 11, 2003 11:18 AM
Subject: [SDL] What Im doing wrong (Event procesing)
Hi everyone. Well I read this list since long time ago but
never
sent any msg, so here I am.
I am having some problems with the performance picking up input events
from the keyboard and I dont know what Im doing wrong.
I have some kind of lag between the moment when I press a key and the
moment when the event is processed. Im working on Windows, I didn’t try it
in
linux yet.
Sometimes while the game is runing I have a high response time, and when
the event is worked it has a reaction like if I press the key twice very
fast .
Is a simple app is a tetris.
When I press the rotation key the most of the time it works fine but
sometimes the tetramino rotate twice just like the event stay stucked . I
dont
know if Im beeing clear.
Could you give me some tips about of how to raise the performace?
Im not using opengl, I use HW surfaces and SW surfaces, and use double
buffering when use software. I have de SDL_Event structure in the main. And
I use the sdl timer to keep the frame rate uniform.
If you want more detail just ask.
Thanks
Martin G
SDL mailing list
SDL@libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl
SDL mailing list
SDL@libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl
SDL mailing list
SDL@libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl