From d53f8b32e9196b369e21473cc36e2d2bd6c3ea47 Mon Sep 17 00:00:00 2001 From: Teo-CD Date: Sat, 8 Jun 2019 01:54:58 +0200 Subject: [PATCH] Moved the clock check outside of the event loop It caused the game to update only if events were received (Mouse movement, button press, etc) --- README.md | 2 +- src/Game.cpp | 10 +++++----- tests/gTests.cpp | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 5830649..acb88d6 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ This game is aimed to be a puzzle game in which the player sets different laws f - [ ] Entities - [x] Structure - [x] Parsing from XML - - [ ] Moving + - [x] Moving - [ ] Decorators (Rules) - [ ] Rules - [ ] Creation diff --git a/src/Game.cpp b/src/Game.cpp index 23b2e81..b1c7df0 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -51,11 +51,11 @@ void Game::runGame() { window.close(); } - if (clock.getElapsedTime().asMilliseconds() >= 200) - { - currentLevel->runStep(); - clock.restart(); - } + } + if (clock.getElapsedTime().asMilliseconds() >= 200) + { + currentLevel->runStep(); + clock.restart(); } window.clear(sf::Color::White); // TODO : Consider drawing in a sf::RenderTexture to allow positioning the level at a fixed position ? diff --git a/tests/gTests.cpp b/tests/gTests.cpp index 6997d4a..bcdb5ff 100644 --- a/tests/gTests.cpp +++ b/tests/gTests.cpp @@ -7,7 +7,7 @@ #include "Game.h" -TEST(Setup,LevelSetup) +TEST(Setup,GameSetup) { // TODO : Think about parsing from file ? Currently cumbersome and error-prone std::vector textures = {"Head_Boy.png","Head_Significant_Boy.png","Building.png"};