commit adee3025ffab5387f7b50d118998a26e56a747ff
parent 3d5248560bac8414c34da47fe0794b2ae0ada848
Author: amin <dev@aminmesbah.com>
Date: Sun, 10 Dec 2017 22:37:50 +0000
Make UPS equal FPS when recording or playing back
This makes recorded input played back over an initial state result in a
consistent sequence of resulting states every time.
This is just temporary. I need to figure out what kind of game loop this
game needs. But for now at least playback is consistent.
FossilOrigin-Name: 39aaa07c0b2ca90fff0e3bec2ff25d37f059b90f7cc7004747d893688bacd585
Diffstat:
1 file changed, 11 insertions(+), 0 deletions(-)
diff --git a/src/platform_sdl.c b/src/platform_sdl.c
@@ -392,6 +392,17 @@ int main(int argc, char *argv[])
{
lag = 0;
}
+ else if (input_record.state == RECORDING || input_record.state == PLAYING_BACK)
+ {
+ // TODO: Make up your mind about what kind of time step and game loop this game needs.
+
+ // When recording or playing back, we do exactly one update
+ // per frame. This is so that recorded input played back
+ // over the initial state always results in the same
+ // sequence of states.
+ game_code.game_update(&game_state, controller_input, buffer.width, buffer.height);
+ lag -= MS_PER_UPDATE;
+ }
else
{
while (lag >= MS_PER_UPDATE)