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

Author Topic: Handling time to delay?  (Read 2270 times)

0 Members and 1 Guest are viewing this topic.

Jimicro

  • Newbie
  • *
  • Posts: 31
    • View Profile
Handling time to delay?
« on: January 09, 2011, 08:33:29 pm »
Hi all.

I have a little game with a shooting feature I want to hold down a button to shoot but I donĀ“t want it to shoot all the time, so can I use sf::Clock to just make it wait between all generating shots?

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Handling time to delay?
« Reply #1 on: January 09, 2011, 08:39:18 pm »
Depends entirely on how you design the game. For optimal you would probably only want one clock in the entire game. But using several clocks for something like that will work too :)
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Handling time to delay?
« Reply #2 on: January 10, 2011, 02:44:08 pm »
You can also measure the frame time using this method, and subtract it from a float counter. When the value gets below zero, reset it and perform your action (e.g. fire a bullet).
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

 

anything