Fix Delay compensation
This commit is contained in:
parent
4da430a02b
commit
e4f7fca02d
|
@ -26,19 +26,20 @@ pub fn main() !void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const start = SDL.getTicks64();
|
||||||
|
|
||||||
current_state = switch (current_state) {
|
current_state = switch (current_state) {
|
||||||
.main_menu => main_menu.tick(),
|
.main_menu => main_menu.tick(),
|
||||||
.game => game.tick(),
|
.game => game.tick(),
|
||||||
};
|
};
|
||||||
const start = SDL.getTicks64();
|
|
||||||
|
|
||||||
|
|
||||||
renderer.render();
|
renderer.render();
|
||||||
|
|
||||||
const delay = SDL.getTicks64() - start;
|
const delay = SDL.getTicks64() - start;
|
||||||
std.debug.print("{} ms\n", .{delay});
|
std.debug.print("{} ms\n", .{delay});
|
||||||
if (delay < 16) {
|
if (delay < 15) {
|
||||||
SDL.delay(16 - @intCast(u32, delay));
|
SDL.delay(15 - @intCast(u32, delay));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue