aboutsummaryrefslogtreecommitdiff
path: root/src/game/game.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/game.cpp')
-rw-r--r--src/game/game.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/game/game.cpp b/src/game/game.cpp
index 18db133..b9f5e3a 100644
--- a/src/game/game.cpp
+++ b/src/game/game.cpp
@@ -7,6 +7,7 @@
#include <fmt/core.h>
+#include <chrono>
#include <iostream>
#include <utility>
@@ -35,6 +36,7 @@ void Game::on_start() noexcept
_status_manager->set_section_title(StatusLineSection::C, "Y: ");
_status_manager->set_section_title(StatusLineSection::D, "Paused: ");
_status_manager->set_section_title(StatusLineSection::E, "Generation: ");
+ _status_manager->set_section_title(StatusLineSection::F, "Time since last frame: ");
std::shared_ptr<ISubscriber<Vector2>> vector2_statusline_subscriber_adapter =
_vector2_statusline_subscriber_adapter_factory(
@@ -66,9 +68,23 @@ void Game::on_start() noexcept
_generation_tracker->get_is_paused() ? "yes" : "no");
_status_manager->set_section_body(StatusLineSection::E, "0");
+
+ _status_manager->set_section_body(StatusLineSection::F, "0");
+
+ _last_update_time = std::chrono::system_clock::now();
}
-void Game::on_update() noexcept {}
+void Game::on_update() noexcept
+{
+ const auto time_since_last_update =
+ std::chrono::system_clock::now() - _last_update_time;
+
+ _status_manager->set_section_body(
+ StatusLineSection::F,
+ fmt::format("{} nanoseconds", time_since_last_update.count()));
+
+ _last_update_time = std::chrono::system_clock::now();
+}
void Game::on_exit() const noexcept
{