clan::GameTime Class Reference - ClanLib SDK
Description: clan::GameTime Class Reference

Public Member Functions | List of all members
clan::GameTime Class Reference
clanCore System

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.
float | get_current_time () const
| Returns the number of seconds since this class was reset()
uint64_t | get_current_time_microseconds () const
| Returns the number of microseconds since this class was reset()
uint64_t | get_current_time_ms () const
| Returns the number of milliseconds since this class was reset()
float | get_tick_interpolation_time () const
| Returns the current time between ticks as a normalized number.
float | get_tick_time_elapsed () const
| Returns the time elapsed per tick.
int | get_tick_time_elapsed_ms () const
| Returns the time elapsed per tick in milliseconds.
int | get_ticks_elapsed () const
| Returns the number of ticks that elapsed since last update.
float | get_time_elapsed () const
| Returns the time elapsed in seconds since last update.
uint64_t | get_time_elapsed_microseconds () const
| Returns the time elapsed in seconds since last update in microseconds.
int | get_time_elapsed_ms () const
| Returns the time elapsed in seconds since last update in milliseconds.
float | get_updates_per_second () const
| Returns the number of updates that occurred every second (aka fps, frames per second)
void | reset ()
| Resets the timer.
void | update ()
| Updates time data for the frame to be rendered.

## Detailed Description

Tracks time elapsed in various forms useful for games.

## Constructor & Destructor Documentation

## ◆ GameTime()

clan::GameTime::GameTime | ( | int | ticks_per_second = 20,
|  | int | max_updates_per_second = 0 )

GameTime constructor.

Parameters

  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

## Member Function Documentation

## ◆ get_current_time()

float clan::GameTime::get_current_time | ( |  | ) | const

Returns the number of seconds since this class was reset()

## ◆ get_current_time_microseconds()

uint64_t clan::GameTime::get_current_time_microseconds | ( |  | ) | const

Returns the number of microseconds since this class was reset()

## ◆ get_current_time_ms()

uint64_t clan::GameTime::get_current_time_ms | ( |  | ) | const

Returns the number of milliseconds since this class was reset()

## ◆ get_tick_interpolation_time()

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.

## ◆ get_tick_time_elapsed()

float clan::GameTime::get_tick_time_elapsed | ( |  | ) | const

Returns the time elapsed per tick.

## ◆ get_tick_time_elapsed_ms()

int clan::GameTime::get_tick_time_elapsed_ms | ( |  | ) | const

Returns the time elapsed per tick in milliseconds.

## ◆ get_ticks_elapsed()

int clan::GameTime::get_ticks_elapsed | ( |  | ) | const

Returns the number of ticks that elapsed since last update.

## ◆ get_time_elapsed()

float clan::GameTime::get_time_elapsed | ( |  | ) | const

Returns the time elapsed in seconds since last update.

## ◆ get_time_elapsed_microseconds()

uint64_t clan::GameTime::get_time_elapsed_microseconds | ( |  | ) | const

Returns the time elapsed in seconds since last update in microseconds.

## ◆ get_time_elapsed_ms()

int clan::GameTime::get_time_elapsed_ms | ( |  | ) | const

Returns the time elapsed in seconds since last update in milliseconds.

## ◆ get_updates_per_second()

float clan::GameTime::get_updates_per_second | ( |  | ) | const

Returns the number of updates that occurred every second (aka fps, frames per second)

## ◆ reset()

void clan::GameTime::reset | ( |  | ) |

Resets the timer.

## ◆ update()

void clan::GameTime::update | ( |  | ) |

Updates time data for the frame to be rendered.

Call this function once at the start of a frame.

The documentation for this class was generated from the following file:

- game_time.h