diff options
author | chai <chaifix@163.com> | 2018-07-28 22:46:38 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-07-28 22:46:38 +0800 |
commit | 178d7eea3903f41d6260777f8058a898d9107a31 (patch) | |
tree | 8e7145cb460903ccc3d06a4502739b5fb52566e3 /src/libjin/Core/Game.cpp | |
parent | 52693d68f7181d707e1a192d67a617145b358394 (diff) |
*update
Diffstat (limited to 'src/libjin/Core/Game.cpp')
-rw-r--r-- | src/libjin/Core/Game.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/libjin/Core/Game.cpp b/src/libjin/Core/Game.cpp index 4509478..ffd8015 100644 --- a/src/libjin/Core/Game.cpp +++ b/src/libjin/Core/Game.cpp @@ -25,6 +25,7 @@ namespace core _running = true; Event e; int previous = getMilliSecond(); + float dt = MS_PER_UPDATE / 1000.0f; while (_running) { while (jin::input::pollEvent(&e)) @@ -32,13 +33,18 @@ namespace core SAFECALL(_onEvent, &e); if (!_running) goto stoploop; } - SAFECALL(_onUpdate); + SAFECALL(_onUpdate, dt); SAFECALL(_onDraw); + wnd->swapBuffers(); const int current = getMilliSecond(); + dt = (current - previous) / 1000.0f; const int wait = MS_PER_UPDATE - (current - previous); previous += MS_PER_UPDATE; if (wait > 0) + { sleep(wait); + dt = MS_PER_UPDATE / 1000.0f; + } else previous = current; } |