Skip to content

Commit

Permalink
Add configurable sleep time when win/lose screen is shown.
Browse files Browse the repository at this point in the history
  • Loading branch information
przemek83 committed Oct 7, 2024
1 parent e308728 commit 30094f9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -54,4 +63,6 @@ class Config
int statusWidth_{0};
float speedFactor_{0};
const std::chrono::seconds fireDelay_{2};

int defaultSleepTimeInSeconds_{2};
};
3 changes: 2 additions & 1 deletion src/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 30094f9

Please sign in to comment.