summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmin Mesbah <mesbahamin@gmail.com>2017-12-10 14:37:51 -0800
committerAmin Mesbah <mesbahamin@gmail.com>2017-12-10 14:37:51 -0800
commit7ea4f54b70e07ebc229e443cc818e8d2d10d8eac (patch)
tree5e7798e6baf251038be2f68aedbbbbe50208bb93
parent150436a59771ce18483305e05a1599988ae78df4 (diff)
downloadohsp-7ea4f54b70e07ebc229e443cc818e8d2d10d8eac.zip
ohsp-7ea4f54b70e07ebc229e443cc818e8d2d10d8eac.tar.gz
Make UPS equal FPS when recording or playing backfeatures/state-looping
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.
-rw-r--r--src/platform_sdl.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/platform_sdl.c b/src/platform_sdl.c
index c7bfbb3..22168e6 100644
--- 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)