From: Brendan Hansen Date: Sat, 18 Dec 2021 00:17:43 +0000 (-0600) Subject: proper delta time X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=c4728efb1e4406d7f047e6ed23d40d10ad392724;p=voxel-shooter.git proper delta time --- diff --git a/src/main.onyx b/src/main.onyx index 2e3b932..f6cca9f 100644 --- a/src/main.onyx +++ b/src/main.onyx @@ -303,9 +303,16 @@ draw :: () { } main_loop :: () { + last := glfwGetTime(); + now := last; + while !glfwWindowShouldClose(window) { glfwPollEvents(); - update(1.0f / 60); + + now = glfwGetTime(); + dt := now - last; + last = now; + update(~~dt); draw(); } }