Clamp dt: mitigate weird regain focus behavior

This commit is contained in:
Stephen Seo 2023-08-09 13:39:43 +09:00
parent cbcf0da5ce
commit cab92d140b

View file

@ -3,6 +3,9 @@
// local includes
#include "screen_trunner.h"
// third party includes
#include <raymath.h>
Game::Game()
: screen_stack(ScreenStack::new_instance()),
prev_time(std::chrono::steady_clock::now()) {
@ -14,7 +17,7 @@ void Game::update() {
auto duration = std::chrono::duration_cast<std::chrono::microseconds>(
next_time - prev_time);
prev_time = next_time;
screen_stack->update(((float)duration.count()) / 1000000);
screen_stack->update(Clamp(((float)duration.count()) / 1000000, 0.0F, 1.0F));
}
void Game::draw() { screen_stack->draw(); }