diff options
Diffstat (limited to 'src/crepe/api/LoopTimer.h')
-rw-r--r-- | src/crepe/api/LoopTimer.h | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/src/crepe/api/LoopTimer.h b/src/crepe/api/LoopTimer.h index 9393439..e348628 100644 --- a/src/crepe/api/LoopTimer.h +++ b/src/crepe/api/LoopTimer.h @@ -6,13 +6,7 @@ namespace crepe { class LoopTimer { public: - /** - * \brief Get the singleton instance of LoopTimer. - * - * \return A reference to the LoopTimer instance. - */ - static LoopTimer & get_instance(); - + LoopTimer(); /** * \brief Get the current delta time for the current frame. * @@ -35,7 +29,7 @@ public: * * \param fps The desired frames rendered per second. */ - void set_fps(int fps); + void set_target_fps(int fps); /** * \brief Get the current frames per second (FPS). @@ -68,7 +62,6 @@ private: * Initializes the timer to begin tracking frame times. */ void start(); - /** * \brief Enforce the frame rate limit. * @@ -97,12 +90,7 @@ private: */ double get_lag() const; - /** - * \brief Construct a new LoopTimer object. - * - * Private constructor for singleton pattern to restrict instantiation outside the class. - */ - LoopTimer(); + /** * \brief Update the timer to the current frame. @@ -121,8 +109,10 @@ private: void advance_fixed_update(); private: - //! Current frames per second - int fps = 50; + //! Target frames per second + int target_fps = 50; + //! Actual frames per second + int actual_fps = 0; //! Current game scale double game_scale = 1; //! Maximum delta time in seconds to avoid large jumps @@ -130,7 +120,7 @@ private: //! Delta time for the current frame in seconds std::chrono::duration<double> delta_time{0.0}; //! Target time per frame in seconds - std::chrono::duration<double> frame_target_time = std::chrono::duration<double>(1.0) / fps; + std::chrono::duration<double> frame_target_time = std::chrono::duration<double>(1.0) / target_fps; //! Fixed delta time for fixed updates in seconds std::chrono::duration<double> fixed_delta_time = std::chrono::duration<double>(1.0) / 50.0; //! Total elapsed game time in seconds @@ -139,6 +129,7 @@ private: std::chrono::duration<double> elapsed_fixed_time{0.0}; //! Time of the last frame std::chrono::steady_clock::time_point last_frame_time; + }; } // namespace crepe |