ohsp

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

commit 150436a59771ce18483305e05a1599988ae78df4
parent 6d77e0f78aa203c44661d8b88e489a65bbc4b56c
Author: Amin Mesbah <mesbahamin@gmail.com>
Date:   Sun, 19 Nov 2017 21:55:38 -0800

Add ability to skip screen clearing

- t key toggles 'trace'

Note that this exposes the non-determinism of the current game loop. The
lag compensation while-loop updates the game state, but not the input.
The variance in the number of these updates causes divergent results
even when identical input is played over a given initial state.

Diffstat:
Msrc/platform_sdl.c | 10+++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/platform_sdl.c b/src/platform_sdl.c @@ -17,6 +17,7 @@ extern bool PAUSED; static struct SDLOffscreenBuffer global_back_buffer = {0}; static struct SDLInputRecord input_record = {0}; +static bool TRACE = false; struct SDLWindowDimension sdl_get_window_dimension(SDL_Window *window) @@ -117,6 +118,10 @@ bool sdl_handle_event(SDL_Event *event, struct GameControllerInput *controller_i { PAUSED = !PAUSED; } + else if (key_code == SDLK_t) + { + TRACE = !TRACE; + } else if (key_code == SDLK_r) { if (input_record.state == INACTIVE) @@ -397,7 +402,10 @@ int main(int argc, char *argv[]) } } - clear_screen(&global_back_buffer, COLOR_BACKGROUND); + if (!TRACE) + { + clear_screen(&global_back_buffer, COLOR_BACKGROUND); + } game_code.game_render(&buffer, lag/SECOND, &game_state); sdl_update_window(renderer, &global_back_buffer); if (elapsed_ms <= MS_PER_FRAME)