SFML community forums
Help => Graphics => Topic started by: mongrol on July 11, 2009, 01:24:04 pm
-
Hi folks,
In my turn based game I have a key A that executes an attack function. he function seems to endlessly repeat until the target runs out of health effectively creating a one shot kill situation. ;)
If I insert a std::cout << ""; statement in the function then it only executes once. Or it's executing a lot slower.
Any clues what's going on here and how to prevent it. Disabling keyrepeat on the window doesn't help.
-
std::cout is slow ( mainly with Windows ) so your FPS reduce and your attack function is called less often.
How do you call it ? I mean, do you test with sf::Input if the key is down ? Or do you use sf::Event ?
If you're using sf::Input you need a clock to turn off temporarily the call of the function.
If you're using sf::Event, disabling key repeat should be enough.
-
My fault. I wasn't returning 0 from my event function when nothing was being pressed so it was returning the last event code instead. All fixed.
Thanks,