// // Created by darman on 9/24/26. // #pragma once namespace SiegeDeck::Engine { // Real (wall-clock) time between frames. Drives UI, the card hand, menus, the camera // and UI tweens: things that keep moving while the simulation is paused. // Not pausable and not scaled by game speed; see SimClock for that. class FrameClock { public: // A frame longer than this (window drag, breakpoint, loading hitch) counts as this long, // so nothing driven by Dt() jumps across the screen afterwards. static constexpr double kMaxDt = 0.25; FrameClock(); // Call once at the start of every frame. The first call yields Dt() == 0. void Tick(); // Seconds since the previous Tick(), clamped to kMaxDt. [[nodiscard]] double Dt() const { return dt; } // Sum of all clamped Dt()s: time the game has seen, not wall-clock uptime. [[nodiscard]] double Time() const { return time; } [[nodiscard]] uint64 FrameCount() const { return frameCount; } private: uint64 frequency; uint64 lastCounter; double dt = 0.0; double time = 0.0; uint64 frameCount = 0; }; }