Fix Delay compensation

This commit is contained in:
Dusk 2022-07-28 16:47:45 +02:00
parent 4da430a02b
commit e4f7fca02d
1 changed files with 4 additions and 3 deletions

View File

@ -26,19 +26,20 @@ pub fn main() !void {
}
}
const start = SDL.getTicks64();
current_state = switch (current_state) {
.main_menu => main_menu.tick(),
.game => game.tick(),
};
const start = SDL.getTicks64();
renderer.render();
const delay = SDL.getTicks64() - start;
std.debug.print("{} ms\n", .{delay});
if (delay < 16) {
SDL.delay(16 - @intCast(u32, delay));
if (delay < 15) {
SDL.delay(15 - @intCast(u32, delay));
}
}
}