SUNENGINE 0.0.2
A simple and bright C++ game engine.
 
Loading...
Searching...
No Matches
FreezeTime.h
1// FreezeTime
2// Andre Berthiaume, Jan 2022
3
4#ifndef _FreezeTime
5#define _FreezeTime
6
7#include "AzulCore.h"
8
16class FreezeTime
17{
18private:
22 static const AZUL_KEY FREEZE_KEY = AZUL_KEY::KEY_F10;
23
27 static const AZUL_KEY SINGLE_FRAME_KEY = AZUL_KEY::KEY_F9;
28
32 static const float DEAD_TIME_THRESHOLD;
33
37 const float DEFAULT_FRAME_TIME; // Not static since automatically adjusted to monitor's refesh rate
38
43
48
55 bool HackedKeyRelease(AZUL_KEY k);
56
60 void TestForFreezeKeys();
61
68
69public:
70 FreezeTime();
71 ~FreezeTime() {};
72 FreezeTime(const FreezeTime&) = delete;
73 FreezeTime& operator=(const FreezeTime&) = delete;
74
81 float ComputeGameTime(float prev_time);
82};
83
84#endif _FreezeTime
Manages the freezing and single frame stepping of the game time.
Definition FreezeTime.h:17
DWORD GetRefreshRate()
Retrieves the refresh rate of the monitor.
Definition FreezeTime.cpp:19
float totalFrozenTime
Total time the game has been frozen.
Definition FreezeTime.h:42
bool HackedKeyRelease(AZUL_KEY k)
Checks if a key has been released (private implementation).
Definition FreezeTime.cpp:82
float ComputeGameTime(float prev_time)
Computes the game time, taking into account any frozen time.
Definition FreezeTime.cpp:26
static const AZUL_KEY FREEZE_KEY
Key to toggle freeze mode.
Definition FreezeTime.h:22
static const AZUL_KEY SINGLE_FRAME_KEY
Key to advance a single frame in freeze mode.
Definition FreezeTime.h:27
bool freeze_mode_active
Indicates if freeze mode is active.
Definition FreezeTime.h:47
const float DEFAULT_FRAME_TIME
Default frame time, adjusted to monitor's refresh rate.
Definition FreezeTime.h:37
static const float DEAD_TIME_THRESHOLD
Threshold for dead time.
Definition FreezeTime.h:32
void TestForFreezeKeys()
Tests for freeze keys and handles their input (private implementation).
Definition FreezeTime.cpp:49