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)
This commit is contained in:
Teo-CD 2019-06-08 01:54:58 +02:00
parent 81364c7b4c
commit d53f8b32e9
3 changed files with 7 additions and 7 deletions

View file

@ -18,7 +18,7 @@ This game is aimed to be a puzzle game in which the player sets different laws f
- [ ] Entities - [ ] Entities
- [x] Structure - [x] Structure
- [x] Parsing from XML - [x] Parsing from XML
- [ ] Moving - [x] Moving
- [ ] Decorators (Rules) - [ ] Decorators (Rules)
- [ ] Rules - [ ] Rules
- [ ] Creation - [ ] Creation

View file

@ -51,11 +51,11 @@ void Game::runGame()
{ {
window.close(); window.close();
} }
if (clock.getElapsedTime().asMilliseconds() >= 200) }
{ if (clock.getElapsedTime().asMilliseconds() >= 200)
currentLevel->runStep(); {
clock.restart(); currentLevel->runStep();
} clock.restart();
} }
window.clear(sf::Color::White); window.clear(sf::Color::White);
// TODO : Consider drawing in a sf::RenderTexture to allow positioning the level at a fixed position ? // TODO : Consider drawing in a sf::RenderTexture to allow positioning the level at a fixed position ?

View file

@ -7,7 +7,7 @@
#include "Game.h" #include "Game.h"
TEST(Setup,LevelSetup) TEST(Setup,GameSetup)
{ {
// TODO : Think about parsing from file ? Currently cumbersome and error-prone // TODO : Think about parsing from file ? Currently cumbersome and error-prone
std::vector<std::string> textures = {"Head_Boy.png","Head_Significant_Boy.png","Building.png"}; std::vector<std::string> textures = {"Head_Boy.png","Head_Significant_Boy.png","Building.png"};