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
5#include "flint/core/api.h"
6
7#include <SDL3/SDL.h>
8
9namespace Flint {
16 class Clock {
17 public:
24 FLINT_API void start();
25
31 FLINT_API void stop();
32
36 FLINT_API void restart();
37
44 FLINT_API Uint64 getElapsedMilliseconds() const;
45
49 FLINT_API float getElapsedSeconds() const;
50
54 FLINT_API bool isRunning() const;
55
56 private:
57 Uint64 m_startTime = 0;
58 Uint64 m_pausedTime = 0;
59 bool m_running = false;
60 };
61
65 class Time {
66 public:
73 FLINT_API static Uint64 s_milliseconds(Uint64 ms);
74
81 FLINT_API static Uint64 s_seconds(float sec);
82 };
83}
A pausable, restartable elapsed-time clock.
Definition time.h:16
FLINT_API float getElapsedSeconds() const
Return the elapsed time in seconds.
FLINT_API bool isRunning() const
Return true if the clock is currently running.
FLINT_API Uint64 getElapsedMilliseconds() const
Return the elapsed time in milliseconds.
FLINT_API void stop()
Stop the clock, preserving the current elapsed time.
FLINT_API void start()
Start the clock if it is currently stopped.
FLINT_API void restart()
Reset the elapsed time to zero and start the clock.
Utility for converting time values to milliseconds.
Definition time.h:65
static FLINT_API Uint64 s_milliseconds(Uint64 ms)
Convert milliseconds to the internal millisecond representation (identity).
static FLINT_API Uint64 s_seconds(float sec)
Convert seconds to milliseconds.