Brief pause after keypress
- by user36324
After i press and hold the key it goes forward once then pauses for a second or less then goes forward on forever. My problem is the brief pause I cant locate the issue. Thanks for your help.
while(game){
while (SDL_PollEvent(&e)){
mainChar.manageEvents(e);
}
background.renderChar();
mainChar.renderChar();
SDL_RenderPresent(ren);
}
void Character::manageEvents(SDL_Event event)
{
switch(event.type){
case SDL_KEYDOWN:
KEYS[event.key.keysym.sym] = true;
printf("true");
handleInput();
break;
case SDL_KEYUP:
KEYS[event.key.keysym.sym] = false;
printf("false");
break;
default:
break;
}
}
void Character::handleInput()
{
if(KEYS[SDLK_a]) {
dst.x--;
}
if(KEYS[SDLK_d]) {
dst.x++;
}
if(KEYS[SDLK_w]) {
dst.y++;
}
if(KEYS[SDLK_s]) {
dst.y--;
}
}