remove the broken variable timestep
This commit is contained in:
		@@ -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;
 | 
			
		||||
 
 | 
			
		||||
@@ -10,11 +10,6 @@
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void game_step(int64_t delta) {
 | 
			
		||||
    (void)delta;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void game_tick(void) {
 | 
			
		||||
    if (ctx.tick_count == 0) {
 | 
			
		||||
        ctx.udata = ccalloc(1, sizeof (struct state));
 | 
			
		||||
 
 | 
			
		||||
@@ -7,7 +7,6 @@
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void game_step(int64_t delta);
 | 
			
		||||
void game_tick(void);
 | 
			
		||||
void game_end(void);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										29
									
								
								src/main.c
									
									
									
									
									
								
							
							
						
						
									
										29
									
								
								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;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user