Replies: 2 comments 2 replies
-
That said, real-time independent and explicitly ticked timers might work better when pausing the game, changing its speed, or saving, loading or rolling back the game state. Also, since duration is represented by |
Beta Was this translation helpful? Give feedback.
2 replies
-
I guess another option is to have timers automatically register themselves with a central timer registry and make that registry tick them automatically. But that comes with some overhead for creating timers. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Both the
Timer
andStopwatch
APIs need you to tick them, i.e. periodically update them in one of your systems. Is this actually necessary?Imagine a
Timer
class that - instead of storing aelapsed: Duration
member just stores astart: Instant
member. Such a timer wouldn't need to be ticked, but we'd have to change theelapsed()
function to take aTime&
argument so that we can calculate it on the fly. Because of that, it's not a clear win but it's a different way of doing this.In my personal opinion, however, that's a better way because it is more explicit. You cannot accidentally forget to tick the timer or accidentally tick it twice and get weird behavior in your game. Also, it would likely be more accurate since we don't have as many floating point addition operations.
Beta Was this translation helpful? Give feedback.
All reactions