ohsp

Prototype for a game with dual thruster controls.
Log | Files | Refs | LICENSE

commit 7ea4f54b70e07ebc229e443cc818e8d2d10d8eac
parent 150436a59771ce18483305e05a1599988ae78df4
Author: Amin Mesbah <mesbahamin@gmail.com>
Date:   Sun, 10 Dec 2017 14:37:51 -0800

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.

Diffstat:
Msrc/platform_sdl.c | 11+++++++++++
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)