diff --git a/src/game/Game.py b/src/game/Game.py index 86e1643..ddc760a 100644 --- a/src/game/Game.py +++ b/src/game/Game.py @@ -10,6 +10,7 @@ from game.Map import Map from src.entities.Pickupable import Pickupable from src.entities.Player import Player from src.entities.Statistics import Statistics +from src.game.Timer import Timer class Game: @@ -40,6 +41,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") @@ -49,11 +55,12 @@ class Game: self.map.addEntity(self.player) self.eventManager = EventManager(self, self.player) - self.mainLoop() 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()