![]() |
SAGE
A Simple Academic Game Engine
|
The event timer. More...
#include <SageEventTimer.h>


Public Member Functions | |
| CEventTimer (float, bool=false) | |
| Constructor. | |
| CEventTimer (float, float, bool=false) | |
| Constructor. | |
| bool | Triggered () |
| Check if triggered. | |
| void | SetDelay (const float) |
| Set fixed delay between events. | |
| void | SetDelay (const float, const float) |
| Set delay between events. | |
| void | Start () |
| Start event. | |
Additional Inherited Members | |
Static Protected Attributes inherited from Sage::CComponent | |
| static std::unique_ptr< CTimer > | m_pTimer = std::make_unique<CTimer>() |
| Pointer to a timer. | |
| static std::unique_ptr< CRandom > | m_pRandom = std::make_unique<CRandom>() |
| Pointer to a PRNG. | |
| static std::unique_ptr< CSound > | m_pSound = std::make_unique<CSound>() |
| Pointer to sound manager. | |
| static std::unique_ptr< CKeyboard > | m_pKeyboard |
| Pointer to a keyboard handler. | |
| static std::unique_ptr< CMouse > | m_pMouse = std::make_unique<CMouse>() |
| Pointer to a mouse handler. | |
| static std::unique_ptr< CController > | m_pController |
| Pointer to a controller. | |
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.
| CEventTimer::CEventTimer | ( | float | fFixed, |
| bool | bOnce = false ) |
Set the last trigger time to now and compute the current delay time.
| fFixed | The fixed delay component. |
| bOnce | True if event happens once. Defaults to false. |
| CEventTimer::CEventTimer | ( | float | fFixed, |
| float | fVariable, | ||
| bool | bOnce = false ) |
Set the last trigger time to now and compute the current delay time.
| fFixed | The fixed delay component. |
| fVariable | The fixed delay component. |
| bOnce | True if event happens once. Defaults to false. |
| void CEventTimer::SetDelay | ( | const float | ft | ) |
Set the fixed delay and make the variable delay zero, compute the current delay.
| ft | Fixed delay time. |
| void CEventTimer::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. |
| void CEventTimer::Start | ( | ) |
Start the event.
| bool CEventTimer::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.