Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Сooldown key presses  (Read 2237 times)

0 Members and 1 Guest are viewing this topic.

vasyaslife

  • Newbie
  • *
  • Posts: 8
    • View Profile
    • Email
Сooldown key presses
« 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?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10815
    • View Profile
    • development blog
    • Email
Re: Сooldown key presses
« Reply #1 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. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything