Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    How can i make a (timer)?

    Beginners
    5
    6
    421
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • landein207
      landein207 last edited by

      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()?

      1 Reply Last reply Reply Quote 0
      • P
        petermeisenstein F last edited by

        Look in the help. There you can find timerstart and timerstop

        1 Reply Last reply Reply Quote 0
        • Hector1945
          Hector1945 F last edited by

          setTimer()
          Look at the docs: https://fuzearena.com/help/view/setTimer

          1 Reply Last reply Reply Quote 0
          • Martin
            Martin Fuze Team last edited by

            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.

            1 Reply Last reply Reply Quote 1
            • landein207
              landein207 last edited by

              Oh lol thanks i didn't saw set timer :P

              1 Reply Last reply Reply Quote 0
              • T
                tony7059 last edited by Martin

                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! : )

                1 Reply Last reply Reply Quote 2
                • First post
                  Last post