aboutsummaryrefslogtreecommitdiff
path: root/gameloop/include
diff options
context:
space:
mode:
authorWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-09-18 16:52:54 +0200
committerWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-09-18 16:52:54 +0200
commit8bf919f750807060f3ac2c640b8a02300af1733c (patch)
tree7bae57855fc3b98779bdfecbea141e7ec1eed68c /gameloop/include
parent61e382cedd71127033f91551298607e2e78c3809 (diff)
gameloop poc working with variable and constant update
Diffstat (limited to 'gameloop/include')
-rw-r--r--gameloop/include/loopManager.h3
-rw-r--r--gameloop/include/timer.h29
2 files changed, 15 insertions, 17 deletions
diff --git a/gameloop/include/loopManager.h b/gameloop/include/loopManager.h
index 5ed918d..06bcd5f 100644
--- a/gameloop/include/loopManager.h
+++ b/gameloop/include/loopManager.h
@@ -18,9 +18,8 @@ class LoopManager{
bool gameRunning = false;
WindowManager window;
int timeScale = 1;
- float lag = 0.0;
+ float accumulator = 0.0;
double currentTime;
double t = 0.0;
double dt = 0.01;
- state previous;
};
diff --git a/gameloop/include/timer.h b/gameloop/include/timer.h
index 2769e4d..a245e5c 100644
--- a/gameloop/include/timer.h
+++ b/gameloop/include/timer.h
@@ -7,25 +7,24 @@ public:
static LoopTimer& getInstance();
void start();
void update();
- float getDeltaTime() const;
- float getDeltaTimeMs() const;
- float getFixedDeltaTime() const;
+ double getDeltaTime() const;
int getCurrentTime() const;
+ void advanceFixedUpdate();
+ double getFixedDeltaTime() const;
void setFPS(int FPS);
int getFPS() const;
void enforceFrameRate();
- float getLag() const;
+ double 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;
+ int FPS = 50;
+ double gameScale = 1;
+ double maximumDeltaTime = 0.25;
+ double deltaTime;
+ double frameTargetTime = FPS / 1000;
+ double fixedDeltaTime = 0.01;
+ double elapsedTime;
+ double elapsedFixedTime;
+ double time;
+ uint64_t lastFrameTime;
};