23 lines
450 B
C++
23 lines
450 B
C++
#include "core/system/delta_time.hpp"
|
|
|
|
#include <SDL3/SDL.h>
|
|
|
|
namespace DeltaTime {
|
|
|
|
namespace {
|
|
Uint64 last_time_ms = 0;
|
|
}
|
|
|
|
void reset() {
|
|
last_time_ms = SDL_GetTicks();
|
|
}
|
|
|
|
auto tick() -> float {
|
|
const Uint64 NOW_MS = SDL_GetTicks();
|
|
const float DELTA_S = static_cast<float>(NOW_MS - last_time_ms) / 1000.0F;
|
|
last_time_ms = NOW_MS;
|
|
return DELTA_S;
|
|
}
|
|
|
|
} // namespace DeltaTime
|