blob: 2769e4df106cfeeb07e79d4fe5e5ee81c4332c22 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#pragma once
#include <SDL2/SDL.h>
class LoopTimer {
public:
static LoopTimer& getInstance();
void start();
void update();
float getDeltaTime() const;
float getDeltaTimeMs() const;
float getFixedDeltaTime() const;
int getCurrentTime() const;
void setFPS(int FPS);
int getFPS() const;
void enforceFrameRate();
float getLag() const;
private:
LoopTimer();
int FPS = 30;
float frameTargetTime = FPS / 1000;
int lastTime;
float fixedDeltaTime = 2;
float maxDeltaTime = 1;
float fixedTime = 0;
int lastFrameTime;
float deltaTime;
float time = 0;
int frequency;
float lag;
};
|