In a game, would you only use 1 timer?

Started by
2 comments, last by Charles B 19 years, 1 month ago
Hi, in my game I've put in one timer, but I was wondering gameplay wise, would you ever use more than one timer? eg game loop Thanks
Advertisement
That depends entirely on the game. In Tetris, for example, you need one timer for the framerate, and another timer for the dropping blocks. If you have sprites, you will need a timer for when the animation changes. Just add as many as you need.
If everything is based on time deltas, you should only have one official, global timer.
You should have at least one system (real) timer and one game (virtual) timer. Why ? You should be able to freeze and unfreeze the game timer at will. For instance when you enter a breakpoint in debug mode. Ever experienced this : you debug, possibly edit, then continue and your physics get completly unstable because they suddenly have to deal with unmanageable long time deltas. Your game timer can for instance decide to clamp any real delta of time between two game loops superior to 0.1 seconds. This will have the effect of freezing the game when you enter a break point.
"Coding math tricks in asm is more fun than Java"

This topic is closed to new replies.

Advertisement