aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/manager/LoopTimerManager.h
diff options
context:
space:
mode:
authorWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-12-11 15:04:36 +0100
committerWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-12-11 15:04:36 +0100
commitcd708c639c34cbc7d978686e54303c91f15954c0 (patch)
treea469b265dd6e7e362200290cc6267c0dd3927cf5 /src/crepe/manager/LoopTimerManager.h
parentdfa8ffbc03c4c1acd74fd14e54c6ee566a3c445c (diff)
parent68c9e7511ea52c6ee70d052bbdf2923cd68bfa8a (diff)
Merge branch 'wouter/gameloop' of https://github.com/lonkaars/crepe into wouter/gameloop
Diffstat (limited to 'src/crepe/manager/LoopTimerManager.h')
-rw-r--r--src/crepe/manager/LoopTimerManager.h33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/crepe/manager/LoopTimerManager.h b/src/crepe/manager/LoopTimerManager.h
index 61ae6ef..ad522f7 100644
--- a/src/crepe/manager/LoopTimerManager.h
+++ b/src/crepe/manager/LoopTimerManager.h
@@ -5,9 +5,10 @@
#include "Manager.h"
namespace crepe {
-typedef std::chrono::duration<float> Duration_t;
-typedef std::chrono::duration<unsigned long long, std::micro> ElapsedTime_t;
-typedef std::chrono::steady_clock::time_point TimePoint_t;
+
+typedef std::chrono::duration<float> duration_t;
+typedef std::chrono::duration<unsigned long long, std::micro> elapsed_time_t;
+
/**
* \brief Manages timing and frame rate for the game loop.
*
@@ -30,7 +31,7 @@ public:
*
* \return Delta time in seconds since the last frame.
*/
- Duration_t get_delta_time() const;
+ duration_t get_delta_time() const;
/**
* \brief Get the current elapsed time (total time passed )
@@ -40,7 +41,7 @@ public:
*
* \return Elapsed game time in seconds.
*/
- ElapsedTime_t get_elapsed_time() const;
+ elapsed_time_t get_elapsed_time() const;
/**
* \brief Set the target frames per second (FPS).
@@ -81,7 +82,7 @@ public:
*
* \return The unscaled fixed delta time in seconds.
*/
- Duration_t get_fixed_delta_time() const;
+ duration_t get_fixed_delta_time() const;
/**
* \brief Set the fixed_delta_time in seconds.
@@ -102,7 +103,7 @@ public:
*
* \return The fixed delta time, scaled by the current time scale, in seconds.
*/
- Duration_t get_scaled_fixed_delta_time() const;
+ duration_t get_scaled_fixed_delta_time() const;
private:
//! Friend relation to use start,enforce_frame_rate,get_lag,update,advance_fixed_update.
@@ -128,7 +129,7 @@ private:
*
* \return Accumulated lag in seconds.
*/
- Duration_t get_lag() const;
+ duration_t get_lag() const;
/**
* \brief Update the timer to the current frame.
@@ -154,19 +155,21 @@ private:
//! Time scale for speeding up or slowing down the game (0 = pause, < 1 = slow down, 1 = normal speed, > 1 = speed up).
float time_scale = 1;
//! Maximum delta time in seconds to avoid large jumps.
- Duration_t maximum_delta_time{0.25};
+ duration_t maximum_delta_time{0.25};
//! Delta time for the current frame in seconds.
- Duration_t delta_time{0.0};
+ duration_t delta_time{0.0};
//! Target time per frame in seconds
- Duration_t frame_target_time = Duration_t(1.0) / target_fps;
+ duration_t frame_target_time{1.0 / target_fps};
//! Fixed delta time for fixed updates in seconds.
- Duration_t fixed_delta_time = Duration_t(1.0) / 50.0;
+ duration_t fixed_delta_time{1.0 / 50.0};
//! Total elapsed game time in microseconds.
- ElapsedTime_t elapsed_time{0};
+ elapsed_time_t elapsed_time{0};
//! Total elapsed time for fixed updates in microseconds.
- ElapsedTime_t elapsed_fixed_time{0};
+ elapsed_time_t elapsed_fixed_time{0};
+
+ typedef std::chrono::steady_clock::time_point time_point_t;
//! Time of the last frame.
- TimePoint_t last_frame_time;
+ time_point_t last_frame_time;
};
} // namespace crepe