SFML community forums

Help => General => Topic started by: Dreken on September 11, 2012, 11:54:59 pm

Title: Disabling the delay on holding down a key (HELP)
Post by: Dreken on September 11, 2012, 11:54:59 pm
I'm using SFML 2.0-rc, Windows 7, Visual Studio 2010.

Here's my snippet of code:

if (sf::Keyboard::isKeyPressed(sf::Keyboard::W))
{      
new_ypos = old_ypos - movespeed;
}

This sits inside the
while (window.pollEvent(event))
.

So, basically when I hold W, my character moves forward for a second, pauses for about 1 second, then W holds down. I know this is the delay in the operating system. The same thing happens when you hold a key on a text document.

Is there any way to get rid of this so that I don't have to wait for that 1 second delay before the character moves continuously, without changing the OS settings? I know where the OS option is, but I don't want to do this if I want to send the game to other people.

So does SFML have anything, or C++?
Title: Re: Disabling the delay on holding down a key (HELP)
Post by: eXpl0it3r on September 12, 2012, 12:10:24 am
Don't put it inside the event handling loop (while(window.pollEvent(event))), it doesn't make any sense to put it there, since it's not an event, but a 'direct' device access. ;)
Title: Re: Disabling the delay on holding down a key (HELP)
Post by: Dreken on September 12, 2012, 03:58:43 am
Thanks, worked!