remove the broken variable timestep
This commit is contained in:
		@@ -40,7 +40,6 @@ typedef struct context {
 | 
				
			|||||||
    int64_t delta_averager_residual; 
 | 
					    int64_t delta_averager_residual; 
 | 
				
			||||||
    int64_t time_averager[4];
 | 
					    int64_t time_averager[4];
 | 
				
			||||||
    uint64_t tick_count;
 | 
					    uint64_t tick_count;
 | 
				
			||||||
    uint64_t step_count;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* set just once on startup */
 | 
					    /* set just once on startup */
 | 
				
			||||||
    uint64_t random_seed;
 | 
					    uint64_t random_seed;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,11 +10,6 @@
 | 
				
			|||||||
#include <stdint.h>
 | 
					#include <stdint.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void game_step(int64_t delta) {
 | 
					 | 
				
			||||||
    (void)delta;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void game_tick(void) {
 | 
					void game_tick(void) {
 | 
				
			||||||
    if (ctx.tick_count == 0) {
 | 
					    if (ctx.tick_count == 0) {
 | 
				
			||||||
        ctx.udata = ccalloc(1, sizeof (struct state));
 | 
					        ctx.udata = ccalloc(1, sizeof (struct state));
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,7 +7,6 @@
 | 
				
			|||||||
#include <stdint.h>
 | 
					#include <stdint.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void game_step(int64_t delta);
 | 
					 | 
				
			||||||
void game_tick(void);
 | 
					void game_tick(void);
 | 
				
			||||||
void game_end(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 */
 | 
					    /* finally, let's get to work */
 | 
				
			||||||
    poll_events();
 | 
					    while (ctx.frame_accumulator >= ctx.desired_frametime * ctx.update_multiplicity) {
 | 
				
			||||||
    input_state_update(&ctx.input);
 | 
					        for (size_t i = 0; i < ctx.update_multiplicity; ++i) {
 | 
				
			||||||
 | 
					            render_queue_clear();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* do we _always_ have to be dry? */
 | 
					            poll_events();
 | 
				
			||||||
    if (ctx.frame_accumulator >= ctx.desired_frametime * ctx.update_multiplicity) {
 | 
					            input_state_update(&ctx.input);
 | 
				
			||||||
        while (ctx.frame_accumulator >= ctx.desired_frametime * ctx.update_multiplicity) {
 | 
					            game_tick();
 | 
				
			||||||
            for (size_t i = 0; i < ctx.update_multiplicity; ++i) {
 | 
					 | 
				
			||||||
                render_queue_clear();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                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();
 | 
					    render();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -239,7 +227,6 @@ static bool initialize(void) {
 | 
				
			|||||||
    ctx.desired_frametime = ctx.clocks_per_second / TICKS_PER_SECOND;
 | 
					    ctx.desired_frametime = ctx.clocks_per_second / TICKS_PER_SECOND;
 | 
				
			||||||
    ctx.frame_accumulator = 0;
 | 
					    ctx.frame_accumulator = 0;
 | 
				
			||||||
    ctx.tick_count = 0;
 | 
					    ctx.tick_count = 0;
 | 
				
			||||||
    ctx.step_count = 0;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* delta time averaging */
 | 
					    /* delta time averaging */
 | 
				
			||||||
    ctx.delta_averager_residual = 0;
 | 
					    ctx.delta_averager_residual = 0;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user