LWJGL - Continuous key press event without delay
Posted
by
Zarkopafilis
on Game Development
See other posts from Game Development
or by Zarkopafilis
Published on 2013-11-04T19:43:30Z
Indexed on
2013/11/04
22:16 UTC
Read the original article
Hit count: 377
I am checking for key presses and then based on the keys pressed I am moving a square around the screen. I am setting booleans for the keys WASD. But , Whenever I try to keep the key down , it takes a while till it moves continuously (Just a half second stop after a single move.) Any way to get rid of that and make it be "smooth"? Code:
up = false;
down = false;
left = false;
right = false;
reset = false;
while(Keyboard.next()){
if (Keyboard.getEventKeyState()) {
if(Keyboard.isKeyDown(Keyboard.KEY_SPACE)){
reset = false;
}
if(Keyboard.isKeyDown(Keyboard.KEY_W)){
up = true;
}
if(Keyboard.isKeyDown(Keyboard.KEY_S)){
down = true;
}
if(Keyboard.isKeyDown(Keyboard.KEY_A)){
left = true;
}
if(Keyboard.isKeyDown(Keyboard.KEY_D)){
right = true;
}
}
}
© Game Development or respective owner