From 572f61e07643643693dd3788f9fe8cee080ecbdf Mon Sep 17 00:00:00 2001 From: Christoph Heiss Date: Wed, 22 Jun 2016 10:43:47 +0200 Subject: [PATCH] Replace sf::Clock with std::chrono::steady_clock --- rwgame/RWGame.cpp | 8 +++++--- rwgame/RWGame.hpp | 5 ++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/rwgame/RWGame.cpp b/rwgame/RWGame.cpp index 1835f1e8..f2f78892 100644 --- a/rwgame/RWGame.cpp +++ b/rwgame/RWGame.cpp @@ -297,8 +297,8 @@ PlayerController *RWGame::getPlayer() int RWGame::run() { - clock.restart(); - + last_clock_time = clock.now(); + // Loop until the window is closed or we run out of state. while (window.isOpen() && StateManager::get().states.size()) { State* state = StateManager::get().states.back(); @@ -334,7 +334,9 @@ int RWGame::run() break; } - float timer = clock.restart().asSeconds(); + auto now = clock.now(); + float timer = std::chrono::duration(now - last_clock_time).count(); + last_clock_time = now; accum += timer * timescale; RW_PROFILE_BEGIN("Update"); diff --git a/rwgame/RWGame.hpp b/rwgame/RWGame.hpp index f43bfe25..35d76dbd 100644 --- a/rwgame/RWGame.hpp +++ b/rwgame/RWGame.hpp @@ -6,6 +6,7 @@ #include #include #include