SFML community forums

Help => Window => Topic started by: vasyaslife on March 21, 2014, 12:45:16 pm

Title: Сooldown key presses
Post by: vasyaslife on March 21, 2014, 12:45:16 pm
Hello!
I work on my project and there is one question.
I have action-game where the man shoots at the target. If i use

if((event.type == Event::KeyPressed) && (event.key.code == Keyboard::E)) Shot();

then my man shot a lot of! How can I slow down the process?
Maybe with clock help? Or should be used for the addition of one variable that stores reloading?
Title: Re: Сooldown key presses
Post by: eXpl0it3r on March 21, 2014, 01:09:35 pm
Yes, you can utilize a clock and some time variables, that way you can check whether the clock has already reached the cool down time or not. ;)