From 30094f9d2e4d1b50af277f74de7dc1cb7eabf0d2 Mon Sep 17 00:00:00 2001 From: przemek83 <4788832+przemek83@users.noreply.github.com> Date: Mon, 7 Oct 2024 13:01:00 +0200 Subject: [PATCH] Add configurable sleep time when win/lose screen is shown. --- src/Config.h | 11 +++++++++++ src/Game.cpp | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Config.h b/src/Config.h index ef36c45..6951817 100644 --- a/src/Config.h +++ b/src/Config.h @@ -37,6 +37,15 @@ class Config void setFPS(FPS fps); + int getDefaultSleepTimeInSeconds() const + { + return defaultSleepTimeInSeconds_; + } + void setDefaultSleepTimeInSeconds(int seconds) + { + defaultSleepTimeInSeconds_ = seconds; + } + private: Config(); ~Config() = default; @@ -54,4 +63,6 @@ class Config int statusWidth_{0}; float speedFactor_{0}; const std::chrono::seconds fireDelay_{2}; + + int defaultSleepTimeInSeconds_{2}; }; diff --git a/src/Game.cpp b/src/Game.cpp index 6202405..5f192e3 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -125,7 +125,8 @@ void Game::drawEndOfGame(Display& display, const std::string& text) const utils::getMidpoint(Config::getInstance().getBoardHeight()), text); display.refresh(); - std::this_thread::sleep_for(std::chrono::seconds(2)); + std::this_thread::sleep_for(std::chrono::seconds( + Config::getInstance().getDefaultSleepTimeInSeconds())); } bool Game::isGameEnding(Display& display) const