![]() |
The LARC Game Engine
A Simple Game Engine from the Laboratory for Recreational Computing
|
The event timer. More...
#include <EventTimer.h>
Public Member Functions | |
LEventTimer (const float, const float=0.0f) | |
Constructor. More... | |
bool | Triggered () |
Check if triggered. More... | |
void | SetDelay (const float) |
Set fixed delay between events. More... | |
void | SetDelay (const float, const float) |
Set delay between events. More... | |
Additional Inherited Members | |
![]() | |
static LTimer * | m_pTimer = &cTimer |
Pointer to a timer. More... | |
static LRandom * | m_pRandom = &cRandom |
Pointer to a PRNG. More... | |
static LKeyboard * | m_pKeyboard = &cKeyboard |
Pointer to a keyboard handler. More... | |
static LXBoxController * | m_pController = &cController |
Pointer to a XBox controller. More... | |
static LSound * | m_pAudio = &cAudio |
Pointer to an audio player. More... | |
The event timer triggers regularly with a random delay time that consists of a fixed component and a variable component. The current delay time, which is computed each time the event is triggered, is computed to be the fixed delay component plus a random fraction of the variable delay component. Function Triggered() must be called at least once per frame to query and update the event.
LEventTimer::LEventTimer | ( | const float | fFixed, |
const float | fVariable = 0.0f |
||
) |
Set the last trigger time to now and compute the current delay time.
fFixed | The fixed delay component. |
fVariable | The fixed delay component, defaults to 0. |
void LEventTimer::SetDelay | ( | const float | ft | ) |
Set the fixed delay and make the variable delay zero, compute the current delay.
ft | Fixed delay time. |
void LEventTimer::SetDelay | ( | const float | ft, |
const float | vt | ||
) |
Set the fixed and variable delay and compute the current delay.
ft | Fixed delay time. |
vt | Variable delay time. |
bool LEventTimer::Triggered | ( | ) |
The event trigger test. If delay time has passed since last time this event was triggered, then trigger it, that is, record the current time, compute a new delay time, and return true. The new delay time equals the fixed delay component plus a random fraction of the variable delay component. This function must be called at least once per frame to query and update this event.