Round delta times
parent
dd22bacdb8
commit
819f259cfa
|
@ -163,8 +163,8 @@ int main(int argc, char *argv[])
|
|||
const Uint8 *const keyboard_state = SDL_GetKeyboardState(NULL);
|
||||
|
||||
SDL_Event e;
|
||||
const int64_t delta_time = (int64_t) (1000.0f / (float) 60);
|
||||
int64_t render_timer = (int64_t) (1000.0f / (float) fps);
|
||||
const int64_t delta_time = (int64_t) roundf(1000.0f / 60.0f);
|
||||
int64_t render_timer = (int64_t) roundf(1000.0f / (float) fps);
|
||||
while (!game_over_check(game)) {
|
||||
const int64_t begin_frame_time = (int64_t) SDL_GetTicks();
|
||||
|
||||
|
@ -199,7 +199,7 @@ int main(int argc, char *argv[])
|
|||
render_timer -= delta_time;
|
||||
if (render_timer <= 0) {
|
||||
SDL_RenderPresent(renderer);
|
||||
render_timer = (int64_t) (1000.0f / (float) fps);
|
||||
render_timer = (int64_t) roundf(1000.0f / (float) fps);
|
||||
}
|
||||
|
||||
SDL_Delay((unsigned int) max_int64(0, delta_time - (end_frame_time - begin_frame_time)));
|
||||
|
|
Loading…
Reference in New Issue