![]() |
Engine
The Game Engine for Ian Parberry's "Introduction to Game Physics with Box2D"
|
The timer. More...
#include <Timer.h>
Public Member Functions | |
| CTimer () | |
| Constructor. | |
| void | start () |
| Start the timer. | |
| int | time () |
| Return the time in ms. | |
| BOOL | elapsed (int &start, int interval) |
| Has interval ms elapsed since start? | |
| void | beginframe () |
| Freeze the time returned for the duration of this frame. | |
| int | GetLevelStartTime () |
| Get time that the level started. | |
| int | GetLevelElapsedTime () |
| Get elapsed time since the level started. | |
| void | StartLevelTimer () |
| Start the level timer. | |
| void | StopLevelTimer () |
| Stop the level timer. | |
The timer.
The timer allows you to manage game events by duration, rather than on a frame-by-frame basis. This simple version of the timer is based on the Windows API function timeGetTime, which is notoriously inaccurate but perfectly adequate for a simple game demo.
| void CTimer::beginframe | ( | void | ) |
Freeze the time returned for the duration of this frame.
This is the signal that a new animation frame has begun, so that the timer can return the same time value for the duration of this frame.
| int CTimer::elapsed | ( | int & | start, |
| int | interval | ||
| ) |
Has interval ms elapsed since start?
The elapsed function is a useful function for measuring repeating time intervals. Given the start and duration times, this function returns TRUE if the interval is over, and has the side-effect of resetting the start time when that happens, thus setting things up for the next interval.
| start | start of time interval |
| interval | duration of time interval |
| int CTimer::GetLevelElapsedTime | ( | ) |
Get elapsed time since the level started.
| int CTimer::GetLevelStartTime | ( | ) |
Get time that the level started.
| int CTimer::time | ( | ) |
Return the time in ms.
Get current time.
1.8.2