diff options
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/main.cpp b/src/main.cpp index 1059cb6..f6a2de5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -20,6 +20,8 @@ int main() render::state_t render(&window); game::state_t game; interface::state_t interface(&window, &game); + size_t frame = 0; + double before = NAN; window.setVerticalSyncEnabled(false); @@ -29,21 +31,28 @@ int main() game.start(); while (1) { - double now = (nano_clock() - t0) * 1.0e-9; + double now = (nano_clock() - t0) * 1.0e-9, dt; - game.tick(now); - interface.tick(); + if (frame) + dt = now - before; + else + dt = 0.01; + + game.tick(now, dt); + interface.tick(dt); if (!window.isOpen()) break; window.clear(); - render.begin_frame(now); + render.begin_frame(now, dt); render.render(&game); interface.render_to(&render); render.end_frame(); + + before = now; + frame++; } game.stop(); - return 0; } |