forked from jaildesigner-jailgames/jaildoctors_dilemma
migrat Logo a time based
This commit is contained in:
27
source/utils/delta_timer.hpp
Normal file
27
source/utils/delta_timer.hpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <algorithm>
|
||||
|
||||
class DeltaTimer {
|
||||
public:
|
||||
DeltaTimer() noexcept;
|
||||
|
||||
// Calcula delta en segundos y actualiza el contador interno
|
||||
float tick() noexcept;
|
||||
|
||||
// Devuelve el delta estimado desde el último tick sin actualizar el contador
|
||||
float peek() const noexcept;
|
||||
|
||||
// Reinicia el contador al valor actual o al valor pasado (en performance counter ticks)
|
||||
void reset(Uint64 counter = 0) noexcept;
|
||||
|
||||
// Escala el tiempo retornado por tick/peek, por defecto 1.0f
|
||||
void setTimeScale(float scale) noexcept;
|
||||
float getTimeScale() const noexcept;
|
||||
|
||||
private:
|
||||
Uint64 last_counter_;
|
||||
double perf_freq_;
|
||||
float time_scale_;
|
||||
};
|
||||
Reference in New Issue
Block a user