SFML community forums

Help => General => Topic started by: Jimicro on January 09, 2011, 08:33:29 pm

Title: Handling time to delay?
Post by: Jimicro 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?
Title: Handling time to delay?
Post by: Groogy 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 :)
Title: Handling time to delay?
Post by: Nexus on January 10, 2011, 02:44:08 pm
You can also measure the frame time using this (http://www.sfml-dev.org/documentation/2.0/classsf_1_1Window.htm#a63571ef14c9351899bcd605fb101c254) 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).