diff --git a/src/context.h b/src/context.h index 7b4862d..f145fd0 100644 --- a/src/context.h +++ b/src/context.h @@ -40,7 +40,6 @@ typedef struct context { int64_t delta_averager_residual; int64_t time_averager[4]; uint64_t tick_count; - uint64_t step_count; /* set just once on startup */ uint64_t random_seed; diff --git a/src/game/game.c b/src/game/game.c index 1808774..26f1812 100644 --- a/src/game/game.c +++ b/src/game/game.c @@ -10,11 +10,6 @@ #include -void game_step(int64_t delta) { - (void)delta; -} - - void game_tick(void) { if (ctx.tick_count == 0) { ctx.udata = ccalloc(1, sizeof (struct state)); diff --git a/src/game/game.h b/src/game/game.h index e89834c..6c67cdb 100644 --- a/src/game/game.h +++ b/src/game/game.h @@ -7,7 +7,6 @@ #include -void game_step(int64_t delta); void game_tick(void); void game_end(void); diff --git a/src/main.c b/src/main.c index 053d789..cb16217 100644 --- a/src/main.c +++ b/src/main.c @@ -120,31 +120,19 @@ void main_loop(void) { } /* finally, let's get to work */ - poll_events(); - input_state_update(&ctx.input); + while (ctx.frame_accumulator >= ctx.desired_frametime * ctx.update_multiplicity) { + for (size_t i = 0; i < ctx.update_multiplicity; ++i) { + render_queue_clear(); - /* do we _always_ have to be dry? */ - if (ctx.frame_accumulator >= ctx.desired_frametime * ctx.update_multiplicity) { - while (ctx.frame_accumulator >= ctx.desired_frametime * ctx.update_multiplicity) { - for (size_t i = 0; i < ctx.update_multiplicity; ++i) { - render_queue_clear(); + poll_events(); + input_state_update(&ctx.input); + game_tick(); - game_tick(); - - ctx.frame_accumulator -= ctx.desired_frametime; - ctx.tick_count = (ctx.tick_count % ULLONG_MAX) + 1; - } + ctx.frame_accumulator -= ctx.desired_frametime; + ctx.tick_count = (ctx.tick_count % ULLONG_MAX) + 1; } - } else { - render_queue_clear(); } - /* the "step" will always run as long as there is time to spare. */ - /* without interpolation, this is preferable to fixed ticks if the additional */ - /* delta time calculations (like in physics code) are acceptable */ - game_step(delta_time); - ctx.step_count = (ctx.step_count % ULLONG_MAX) + 1; - render(); } @@ -239,7 +227,6 @@ static bool initialize(void) { ctx.desired_frametime = ctx.clocks_per_second / TICKS_PER_SECOND; ctx.frame_accumulator = 0; ctx.tick_count = 0; - ctx.step_count = 0; /* delta time averaging */ ctx.delta_averager_residual = 0;