How can i make a (timer)?
-
So im trying to do a timer but sleep(amount of time)
slows all the loop making a blinking game, how can i make a timer without sleep()? -
Look in the help. There you can find timerstart and timerstop
-
setTimer()
Look at the docs: https://fuzearena.com/help/view/setTimer -
Depends what you want to do, how much flexibility you want over it and whether you want it to be time based or game loop based. As already mentioned you have timers in Fuze (look in the help). They can be set to call a function once after a period of time or once after every repeated period of time.
Another way to do it if you want it 'frame' based or 'game loop' based (another way to put it) is something like this:
int counter1 = 0 int counter2 = 0 // Or use an array to hold multiples function updateCounters() counter1 += 1 // etc return void // Main loop loop clear() update() updateCounters() repeat
You could update your counters at the start or end of the loop, whicever you prefer. The fundamental difference to doing this over a timer is that these will go at the same rate as your FPS so if it slows, so will your counters. Also, you may want to speed up, slow down or even reverse your counters under certain game conditions. You can do that here, you can't easily do that with timers.
-
Oh lol thanks i didn't saw set timer :P
-
If you really want to do this manually, I think there a deltaTime value, where you'd create your own variable to += deltaTime until some goal. I don't have the doc in front of me to find the exact name of that command. This value would be the time that passed since the last pass through the game loop. Aha... looked it up... it's the function, deltaTime(). Doc states that this can be used with updateSprite() to change the speed of the sprite action... Interest! : )