#include #include "./constants.h" int last_frame_time = 0; void delay(void) { // logic to keep a fixed timestep int time_to_wait = FRAME_TARGET_TIME - (SDL_GetTicks() - last_frame_time); if(time_to_wait > 0 && time_to_wait <= FRAME_TARGET_TIME) { SDL_Delay(time_to_wait); } } float get_delta_time() { // get a delta time factor converted to seconds float delta_time = (SDL_GetTicks() - last_frame_time) / 1000.0f; last_frame_time = SDL_GetTicks(); return delta_time; }