iatneH
Still Fresh
I've been working on a game as my first project for a few weeks now using SDL, I just have a question about the SDL event queue, more specifically how exactly it works.
Just for context, I'm making a 2D scrolling shooter. I noticed that if I really quickly mash around the directional keys and then let go, the ship keeps moving around for a while after I stop.
What it looks like is that the inputs aren't being interpreted in real time, but what is strange is that the screen keeps scrolling at the same speed it always has.
So are all the events are just being shoved into a queue and being interpreted at a later time? But how can I make it so that inputs are always registered in one VBlank period and interpreted for the next VBlank?
What the general form of the code looks like now is this:
I have no clue what could be causing the huge input lags... the controls are fine if I make only a few inputs, it's just that it lags to Hell when I mash buttons - the ship could continue moving for several seconds after I stop inputting controls.
Any ideas would be much appreciated, thanks!
Just for context, I'm making a 2D scrolling shooter. I noticed that if I really quickly mash around the directional keys and then let go, the ship keeps moving around for a while after I stop.
What it looks like is that the inputs aren't being interpreted in real time, but what is strange is that the screen keeps scrolling at the same speed it always has.
So are all the events are just being shoved into a queue and being interpreted at a later time? But how can I make it so that inputs are always registered in one VBlank period and interpreted for the next VBlank?
What the general form of the code looks like now is this:
Code:
while (!done)
{
SDL_PollEvent(&event)
switch (event.type)
{
// (key up and key down stuff, basically I'm just putting 1's and 0's into an array here)
}
// other game logic
// including interpreting what was found in the controls array
SDL_Flip(screen);
}
I have no clue what could be causing the huge input lags... the controls are fine if I make only a few inputs, it's just that it lags to Hell when I mash buttons - the ship could continue moving for several seconds after I stop inputting controls.
Any ideas would be much appreciated, thanks!