From f7fb38b7ff77b186f35c26973da81cb67bb435f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Czeka=C5=84ski?= Date: Sun, 5 Apr 2020 23:51:22 +0200 Subject: [PATCH] Bring timer back to Game class --- src/game/Game.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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()