Claire's Game Engine
Full C++ Engine using OpenGL
Loading...
Searching...
No Matches
Time Class Reference

The Time class provides static utility functions and variables to manage frame timing, delta time computation, frame rate regulation, and tracking the elapsed game time. It is designed to be a singleton-style class with only static members and no instances. More...

#include <Time.h>

Public Member Functions

 Time ()=default
 
 Time (const Time &)=delete
 
Timeoperator= (const Time &)=delete
 

Static Public Member Functions

static unsigned int ComputeDeltaTime ()
 Computes the time elapsed since the last frame (delta time), clamps it to a maximum to prevent instability, and stores it in deltaTime.
 
static void DelayTime ()
 Delays the frame if it finished too early, in order to maintain a consistent frame rate defined by FPS.
 
static float GetGameTime ()
 Returns the total time elapsed since the game started.
 

Static Public Attributes

static float deltaTime = 0
 Delta time (in seconds) between the current and previous frame.
 

Detailed Description

The Time class provides static utility functions and variables to manage frame timing, delta time computation, frame rate regulation, and tracking the elapsed game time. It is designed to be a singleton-style class with only static members and no instances.

Constructor & Destructor Documentation

◆ Time() [1/2]

Time::Time ( )
default

◆ Time() [2/2]

Time::Time ( const Time & )
delete

Member Function Documentation

◆ ComputeDeltaTime()

unsigned int Time::ComputeDeltaTime ( )
static

Computes the time elapsed since the last frame (delta time), clamps it to a maximum to prevent instability, and stores it in deltaTime.

Returns
Delta time in milliseconds (clamped to MAX_DT).

◆ DelayTime()

void Time::DelayTime ( )
static

Delays the frame if it finished too early, in order to maintain a consistent frame rate defined by FPS.

◆ GetGameTime()

float Time::GetGameTime ( )
static

Returns the total time elapsed since the game started.

Returns
Elapsed game time in seconds.

◆ operator=()

Time & Time::operator= ( const Time & )
delete

Member Data Documentation

◆ deltaTime

float Time::deltaTime = 0
static

Delta time (in seconds) between the current and previous frame.


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