diff --git a/src/gamestate.cpp b/src/gamestate.cpp index debbcbb..98840d0 100755 --- a/src/gamestate.cpp +++ b/src/gamestate.cpp @@ -30,6 +30,7 @@ namespace snakeplusplus if (isBotControlled) { while (!bot.path.empty()) { bot.path.pop(); } } PrepareGameBoard(); isGameOver = false; + graphics.SetShowGame((amountPlayed + 1) % 50 == 0); return; } @@ -59,7 +60,7 @@ namespace snakeplusplus RegenerateFood(); currentScore = player.body.size() * 100; //bot.UpdateProbability(player.body.size()); - //graphics.DisplayGameState(gameBoard, currentScore); + graphics.DisplayGameState(gameBoard, currentScore); } return; } diff --git a/src/playerinterface.cpp b/src/playerinterface.cpp index 55a7ca3..ff5c26a 100755 --- a/src/playerinterface.cpp +++ b/src/playerinterface.cpp @@ -87,6 +87,7 @@ namespace snakeplusplus void PlayerOutput::DisplayGameState(std::vector< std::vector >& gameBoard, int score) { CheckWindowEvents(); + if (delay == sf::milliseconds(0)) { return; } char* letterOnBoard; for (float y = 0; y < gameBoundaries.y; y++) { @@ -120,6 +121,12 @@ namespace snakeplusplus return; } + void PlayerOutput::SetShowGame(bool isShowing) { + if (isShowing) { delay = sf::milliseconds(2); } + else { delay = sf::milliseconds(0); } + return; + } + void PlayerOutput::CheckWindowEvents(void) { while (gameWindow.pollEvent(event)) diff --git a/src/playerinterface.hpp b/src/playerinterface.hpp index eb0a210..5f5fb3a 100755 --- a/src/playerinterface.hpp +++ b/src/playerinterface.hpp @@ -20,6 +20,7 @@ namespace snakeplusplus void DisplayGameState(std::vector< std::vector >& gameBoard, int score); void DisplayScore(int score); void StartGameWindow(void); + void SetShowGame(bool isShowing); private: void CheckWindowEvents(void); void DisplayEndScreen(void);