![]() |
KTech 1.1.0
C++ 2D terminal game engine library
|
Engine component responsible for game loop timing. More...
#include <time.hpp>
Classes | |
struct | Invocation |
Calls a function after a given time. More... | |
Public Types | |
enum class | Measurement : uint8_t { ticks , seconds , milliseconds , microseconds } |
Time measurement. | |
Public Member Functions | |
void | CallInvocations () |
Call callback functions of finished Invocation s. | |
void | WaitUntilNextTick () |
Sleeps and returns when the next tick should start. | |
Public Attributes | |
unsigned long | tpsLimit |
Max ticks allowed to occur in a second. You set this value in Engine::Engine() , and you can change it whenever you want. | |
float | tps = 0 |
Actual ticks per second. Corresponds to Time::deltaTime . | |
float | tpsPotential = 0 |
Ticks per second if it wasn't limited by Time::tpsLimit . | |
long | deltaTime = 0 |
Duration of the last tick, in microseconds. | |
unsigned long | ticksCounter = 0 |
Total ticks since game started. | |
Friends | |
class | Invocation |
class | Output |
class | Engine |
Engine component responsible for game loop timing.
This engine component schedules ticks (game loop iterations). Its member variables, which hold various information on tick timing, are at your disposal. Time
also manages your Invocation
s.
void KTech::Time::CallInvocations | ( | ) |
Call callback functions of finished Invocation
s.
Progresses all Invocation
s by Time::deltaTime
, and calls those which waited their time.
Normally placed at the start of your game loop, among the other callback-calling functions. For example:
Time::Invoke()
void KTech::Time::WaitUntilNextTick | ( | ) |
Sleeps and returns when the next tick should start.
Calculates how long to sleep (based on how long the current tick is, and Time::tpsLimit
). It enters sleep and returns when the following tick should occur. This function also updates Time::tpsPotential
, Time::deltaTime
, Time::tps
, and Time::ticksCounter
.
Normally placed at the end of your game loop: