diff --git a/src/ticker.cpp b/src/ticker.cpp index de2b3bff..a8675b60 100644 --- a/src/ticker.cpp +++ b/src/ticker.cpp @@ -139,6 +139,11 @@ int Ticker::Unref(Entity *entity) return --entity->ref; } +void Ticker::Setup(float fps) +{ + data->fps = fps; +} + void Ticker::TickGame() { Profiler::Stop(Profiler::STAT_TICK_FRAME); @@ -308,10 +313,12 @@ void Ticker::TickDraw() Profiler::Start(Profiler::STAT_TICK_BLIT); } -void Ticker::ClampFps(float deltams) +void Ticker::ClampFps() { Profiler::Stop(Profiler::STAT_TICK_BLIT); + float deltams = data->fps ? 1000.0f / data->fps : 0.0f; + if (deltams > data->bias + 200.0f) deltams = data->bias + 200.0f; // Don't go below 5 fps if (deltams > data->bias) diff --git a/src/ticker.h b/src/ticker.h index e6fe9079..6d2bc717 100644 --- a/src/ticker.h +++ b/src/ticker.h @@ -28,9 +28,10 @@ public: static void Ref(Entity *entity); static int Unref(Entity *entity); + static void Setup(float fps); static void TickGame(); static void TickDraw(); - static void ClampFps(float deltams); + static void ClampFps(); static int GetFrameNum(); static void Shutdown();