ASGE  3.2.0
Simple Game Framework in GL
ASGE::GameTime Struct Reference

#include <GameTime.hpp>

Public Member Functions

double deltaInSecs () const noexcept
 
double fixedTsInSecs () const noexcept
 

Public Attributes

std::chrono::time_point< std::chrono::steady_clock > last_frame_time
 
std::chrono::time_point< std::chrono::steady_clock > last_fixedstep_time
 
std::chrono::duration< double, std::milli > frame_delta
 
std::chrono::duration< double, std::milli > fixed_delta
 
double distance = 0.0
 
std::chrono::milliseconds elapsed
 

Detailed Description

Stores both frame and game deltas.

Stores various measurements of delta time for the game. It will store the current time point which is used to calculate the delta between frames, the delta of the last frame and the entire delta since the game started. This can be used to control simulations and render functions to use non-fixed time steps.

Definition at line 30 of file GameTime.hpp.

Member Function Documentation

◆ deltaInSecs()

double ASGE::GameTime::deltaInSecs ( ) const
inlinenoexcept

The last frame delta expressed in seconds (double)

Just a shorthand function to convert the chrono::duration of frame_delta in seconds to help with pacing of animations etc. This is purely just to present it in a more user friendly number.

Returns
The last frame delta in seconds.

Definition at line 95 of file GameTime.hpp.

◆ fixedTsInSecs()

double ASGE::GameTime::fixedTsInSecs ( ) const
inlinenoexcept

The fixed delta expressed in seconds (double)

Just a shorthand function to convert the chrono::duration of fixed_delta in seconds to help with simulations and fixed time-step update functions. It is purely just to present it in a more user friendly number.

Returns
The fixed time-step in seconds.

Definition at line 111 of file GameTime.hpp.

Member Data Documentation

◆ distance

double ASGE::GameTime::distance = 0.0

Distance to next fixed update.

Used in combination with fixed time-steps. It represents how far far along (percentage) to the next fixed time step we are. An update call will only happen once this distance is 1.0 or higher. To re-frame, how much simulated time has not yet been processed.

Definition at line 74 of file GameTime.hpp.

◆ elapsed

std::chrono::milliseconds ASGE::GameTime::elapsed

Total running time.

The total amount of time since the start of the game in milliseconds. The longer the game runs the higher this value will be. Could be expanded upon to support pausing by storing the time the game is in a paused state. However, currently the paused data is not exposed.

Definition at line 84 of file GameTime.hpp.

◆ fixed_delta

std::chrono::duration<double, std::milli> ASGE::GameTime::fixed_delta

Fixed delta time.

The delta between each fixed time-step. Use this to create deterministic simulations inside the update function.

@Note This does not reflect the delta in real time between updates, rather it represents the simulated amount of time to aim for between them.

Definition at line 64 of file GameTime.hpp.

◆ frame_delta

std::chrono::duration<double, std::milli> ASGE::GameTime::frame_delta

Frame delta. How long did it take between the previous frame being rendered and the current one starting. This can be used to help interpolate objects using the render (variable time-step) function.

Definition at line 52 of file GameTime.hpp.

◆ last_fixedstep_time

std::chrono::time_point<std::chrono::steady_clock> ASGE::GameTime::last_fixedstep_time
Initial value:
=
std::chrono::steady_clock::now()

Time point of last fixed step update. The time at which the previous update tick began.

Definition at line 43 of file GameTime.hpp.

◆ last_frame_time

std::chrono::time_point<std::chrono::steady_clock> ASGE::GameTime::last_frame_time
Initial value:
=
std::chrono::steady_clock::now()

Time point of last rendered frame. The time at which the previous frame render began.

Definition at line 36 of file GameTime.hpp.


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