Documentation Index
Fetch the complete documentation index at: https://mintlify.com/adi3120/Fazen2d/llms.txt
Use this file to discover all available pages before exploring further.
TimeManager provides frame-to-frame elapsed time measurement using std::chrono::system_clock. It enables frame-rate independent animation so that movement speed stays consistent regardless of how fast or slow the rendering loop runs. Access it via game.timer.
Header
Constructor
TimeManager()
Initializes both internal time_point values by calling Reset() during construction. The timer is ready to use immediately after the Game object is created.
Methods
| Signature | Returns | Description |
|---|---|---|
Reset() | void | Records the current time as the new reference point |
GetElapsedTime() | float | Returns seconds elapsed since the last Reset() call |
void Reset()
Sets the internal reference time point tp1 to std::chrono::system_clock::now(). Call this at the beginning of each frame to start the measurement for the next frame’s delta calculation.
float GetElapsedTime()
Captures std::chrono::system_clock::now() into tp2, computes the duration tp2 - tp1 as a float in seconds, and returns it. Internally advances tp1 to tp2 after measuring, so successive calls measure from the last sample point.
Delta-Time Pattern
Without delta time, an object moving one cell per frame moves faster on a 120 FPS machine than on a 30 FPS machine. Multiplying displacement by the elapsed time since the last frame normalizes speed to cells per second, making behaviour consistent across hardware.GetElapsedTime() returns the wall-clock seconds that the previous iteration took (including rendering), and Reset() immediately starts measuring the next frame.