From d9c4e9b97bdc181c6e5ab8aa80359996139fed16 Mon Sep 17 00:00:00 2001 From: Marcin Kostrzewski Date: Sun, 5 Apr 2020 21:54:35 +0200 Subject: [PATCH] Added timer to main loop --- src/game/Game.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/game/Game.py b/src/game/Game.py index 6c208c7..7ebcb2c 100644 --- a/src/game/Game.py +++ b/src/game/Game.py @@ -36,6 +36,11 @@ class Game: print("The screen cannot be in a vertical orientation. Exiting...") exit(1) + # Initialize timers + self.pgTimer = pygame.time.Clock() + self.ingameTimer = Timer() + self.ingameTimer.startClock() + self.screen = Screen(self, self.config["window"]) print("OK") @@ -45,6 +50,9 @@ class Game: def mainLoop(self): while self.running: + # Update ingame clock + self.ingameTimer.updateTime(self.pgTimer.tick()) + self.eventManager.handleEvents() self.spritesList.draw(self.screen.pygameScreen) pygame.display.flip()