CGPdocs

timer_event_periodic

Timer raising an event at a fixed period (spawn objects regularly).

Derives from: timer_basic

The same irregular frames seen by the three timers: timer_basic.t grows by dt at each update, timer_interval.t loops back to t_min when it reaches t_max, and timer_event_periodic sets event to true at the first frame after each period has elapsed.
The same irregular frames seen by the three timers: timer_basic.t grows by dt at each update, timer_interval.t loops back to t_min when it reaches t_max, and timer_event_periodic sets event to true at the first frame after each period has elapsed. Tap to enlarge.

Fields and methods

Members of the struct timer_event_periodic. Most of what you do with a CGP type goes through the free functions listed below.

Fields

bool eventTrue only after an update() during which event_period elapsed since the previous event, false otherwise.
float t_periodicTime in seconds accumulated since the last event, reset when it reaches event_period.
float event_periodTime in seconds between two events, 1 by default.

Methods

Builds a running timer that raises event every event_period seconds (1 by default). src
Advances t as timer_basic::update(), adds the step to t_periodic and sets event to true if t_periodic reaches event_period (then subtracts event_period, or resets it to 0 if several periods elapsed), and returns the time step. src
Inherited from timer_basic (4 members)

Fields

float tAccumulated time in seconds, multiplied by scale, 0 until the second update().
float scaleMultiplier applied to the elapsed real time (1 by default; larger values accelerate the animation).

Methods

Resumes the timer, measuring the next time step from now (the time spent stopped is not counted). src
Pauses the timer; update() then returns 0 and t stays constant. src

Functions taking a timer_event_periodic

None.

Functions returning a timer_event_periodic

None.

Operators

None.

CGP - Computer Graphics Programming.