Flint Engine
Modular C++20 2D game engine powered by SDL3
Loading...
Searching...
No Matches
time.h
1// SPDX-License-Identifier: MIT
2// SPDX-FileCopyrightText: 2025-2026 Manuel Osorio
3#pragma once
4#include <SDL3/SDL.h>
5
6namespace Flint {
13 class Clock {
14 public:
21 void start();
22
28 void stop();
29
33 void restart();
34
41 Uint64 getElapsedMilliseconds() const;
42
46 float getElapsedSeconds() const;
47
51 bool isRunning() const;
52
53 private:
54 Uint64 m_startTime = 0;
55 Uint64 m_pausedTime = 0;
56 bool m_running = false;
57 };
58
62 class Time {
63 public:
70 static Uint64 s_milliseconds(Uint64 ms);
71
78 static Uint64 s_seconds(float sec);
79 };
80}
void start()
Start the clock if it is currently stopped.
void stop()
Stop the clock, preserving the current elapsed time.
Uint64 getElapsedMilliseconds() const
Return the elapsed time in milliseconds.
A pausable, restartable elapsed-time clock.
Definition time.h:13
bool isRunning() const
Return true if the clock is currently running.
float getElapsedSeconds() const
Return the elapsed time in seconds.
void restart()
Reset the elapsed time to zero and start the clock.
static Uint64 s_seconds(float sec)
Convert seconds to milliseconds.
static Uint64 s_milliseconds(Uint64 ms)
Convert milliseconds to the internal millisecond representation (identity).
Utility for converting time values to milliseconds.
Definition time.h:62