dimanche 24 juillet 2016

SDL- move object via keypress starts slow

I'm trying to move a texture via different key presses, eg

Move function:

if (key[SDL_SCANCODE_LEFT])
{
    mPosX = mPosX - 10;
}
//.....

This is my main loop:

newTexture.move(currentKeyStates);
SDL_RenderClear(gRenderer);
newTexture.render();
SDL_RenderPresent(gRenderer);

So, everything works fine, except when I hold down a button, for example "Left", the texture moves 10px, but then it stops for a few miliseconds. If I continue holding the button, everythings works smoothly. But as soon as I change the direction I got the same problem again.

Aucun commentaire:

Enregistrer un commentaire