Tracks time elapsed in various forms useful for games. More...
#include <game_time.h>
Public Member Functions | |
GameTime (int ticks_per_second=20, int max_updates_per_second=0) | |
GameTime constructor. More... | |
float | get_current_time () const |
Returns the number of seconds since this class was reset() More... | |
uint64_t | get_current_time_microseconds () const |
Returns the number of microseconds since this class was reset() More... | |
uint64_t | get_current_time_ms () const |
Returns the number of milliseconds since this class was reset() More... | |
float | get_tick_interpolation_time () const |
Returns the current time between ticks as a normalized number. More... | |
float | get_tick_time_elapsed () const |
Returns the time elapsed per tick. More... | |
int | get_tick_time_elapsed_ms () const |
Returns the time elapsed per tick in milliseconds. More... | |
int | get_ticks_elapsed () const |
Returns the number of ticks that elapsed since last update. More... | |
float | get_time_elapsed () const |
Returns the time elapsed in seconds since last update. More... | |
uint64_t | get_time_elapsed_microseconds () const |
Returns the time elapsed in seconds since last update in microseconds. More... | |
int | get_time_elapsed_ms () const |
Returns the time elapsed in seconds since last update in milliseconds. More... | |
float | get_updates_per_second () const |
Returns the number of updates that occurred every second (aka fps, frames per second) More... | |
void | reset () |
Resets the timer. More... | |
void | update () |
Updates time data for the frame to be rendered. More... | |
Tracks time elapsed in various forms useful for games.
clan::GameTime::GameTime | ( | int | ticks_per_second = 20 , |
int | max_updates_per_second = 0 |
||
) |
GameTime constructor.
ticks_per_second | = Number of ticks per second |
max_updates_per_second | = Maximum number of updates per second (aka FPS, frames per second). 0 = Unlimited |
float clan::GameTime::get_current_time | ( | ) | const |
Returns the number of seconds since this class was reset()
uint64_t clan::GameTime::get_current_time_microseconds | ( | ) | const |
Returns the number of microseconds since this class was reset()
uint64_t clan::GameTime::get_current_time_ms | ( | ) | const |
Returns the number of milliseconds since this class was reset()
float clan::GameTime::get_tick_interpolation_time | ( | ) | const |
Returns the current time between ticks as a normalized number.
If the current time is half-way between two tick updates this function returns 0.5, at the start of a tick its 0.0, and at the end its 1.0.
float clan::GameTime::get_tick_time_elapsed | ( | ) | const |
Returns the time elapsed per tick.
int clan::GameTime::get_tick_time_elapsed_ms | ( | ) | const |
Returns the time elapsed per tick in milliseconds.
int clan::GameTime::get_ticks_elapsed | ( | ) | const |
Returns the number of ticks that elapsed since last update.
float clan::GameTime::get_time_elapsed | ( | ) | const |
Returns the time elapsed in seconds since last update.
uint64_t clan::GameTime::get_time_elapsed_microseconds | ( | ) | const |
Returns the time elapsed in seconds since last update in microseconds.
int clan::GameTime::get_time_elapsed_ms | ( | ) | const |
Returns the time elapsed in seconds since last update in milliseconds.
float clan::GameTime::get_updates_per_second | ( | ) | const |
Returns the number of updates that occurred every second (aka fps, frames per second)
void clan::GameTime::reset | ( | ) |
Resets the timer.
void clan::GameTime::update | ( | ) |
Updates time data for the frame to be rendered.
Call this function once at the start of a frame.