From cf46b52180e2d256c8e80d638f2dbbdafd20c825 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Tue, 20 Oct 2020 20:19:24 +0200 Subject: [PATCH] Move wrong init --- game.h | 4 ++++ settings.h | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/game.h b/game.h index 2fb4ff4..72cd2d7 100755 --- a/game.h +++ b/game.h @@ -4763,6 +4763,10 @@ uint8_t SFG_mainLoopBody() delta time. */ uint32_t timeNow = SFG_getTimeMs(); +#if SFG_TIME_MULTIPLIER != 1024 + timeNow = (timeNow * SFG_TIME_MULTIPLIER) / 1024; +#endif + int32_t timeSinceLastFrame = timeNow - SFG_game.frameTime; if (timeSinceLastFrame >= SFG_MS_PER_FRAME) diff --git a/settings.h b/settings.h index 2fe4297..69c6acf 100644 --- a/settings.h +++ b/settings.h @@ -19,6 +19,15 @@ #ifndef _SFG_SETTINGS_H #define _SFG_SETTINGS_H +/** + Time multiplier in SFG_Units (1.0 == 1024). This can be used to slow down or + speed up the game. +*/ + +#ifndef SFG_TIME_MULTIPLIER + #define SFG_TIME_MULTIPLIER 1024 +#endif + /** Target FPS (frames per second). This sets the game logic FPS and will try to render at the same rate. If such fast rendering can't be achieved, frames will @@ -34,6 +43,12 @@ #define SFG_FPS 60 #endif +#define SFG_FPS ((SFG_FPS * SFG_TIME_MULTIPLIER) / 1024) + +#if SFG_FPS == 0 + #define SFG_FPS 1 +#endif + /** On platforms with mouse this sets its horizontal sensitivity. 128 means 1 RCL_Unit per mouse pixel travelled.