5#include <aegis2d/core/export.hpp>
20 return Duration{std::chrono::seconds{1}} / ticks_per_second;
35 static constexpr Duration default_max_frame = std::chrono::milliseconds{250};
52 [[nodiscard]]
double alpha() const noexcept;
60 [[nodiscard]]
Duration max_frame() const noexcept;
64 [[nodiscard]]
Duration accumulated() const noexcept;
67 void reset() noexcept;
79 using Clock = std::chrono::steady_clock;
86 [[nodiscard]]
Duration elapsed() const noexcept;
93 Clock::time_point start_;
Turns variable frame times into a whole number of fixed simulation steps.
Definition clock.hpp:32
double alpha() const noexcept
Fraction of a step left in the accumulator.
FixedTimestep(Duration step, Duration max_frame=default_max_frame)
Creates an empty accumulator.
std::size_t advance(Duration elapsed) noexcept
Adds the time elapsed since the previous frame.
Measures elapsed time with the monotonic std::chrono::steady_clock.
Definition clock.hpp:76
std::chrono::steady_clock Clock
Clock the stopwatch reads; it never goes backwards.
Definition clock.hpp:79
Stopwatch() noexcept
Starts measuring from now.
Logging, time, main loop, events and configuration shared by client and server.
Definition clock.hpp:11
std::chrono::nanoseconds Duration
Duration type used for simulation time (nanoseconds).
Definition clock.hpp:14
constexpr Duration step_from_rate(std::uint32_t ticks_per_second) noexcept
Length of one step for a given update rate.
Definition clock.hpp:19