From 43bc25ad91871a646cf13ad5d777ef4a10c6e285 Mon Sep 17 00:00:00 2001 From: livingmentor Date: Fri, 8 Jul 2022 22:47:41 -0400 Subject: [PATCH] Fixed Timer Set the timer to decrement from 120 and "gameOver" when it hits zero. --- classes/Dashboard.py | 2 +- classes/Menu.py | 2 +- main.py | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/classes/Dashboard.py b/classes/Dashboard.py index aeb36e76..cf9f09ac 100644 --- a/classes/Dashboard.py +++ b/classes/Dashboard.py @@ -31,7 +31,7 @@ def update(self): self.ticks += 1 if self.ticks == 60: self.ticks = 0 - self.time += 1 + self.time -= 1 def drawText(self, text, x, y, size): for char in text: diff --git a/classes/Menu.py b/classes/Menu.py index 57d8f687..61d1fbb4 100644 --- a/classes/Menu.py +++ b/classes/Menu.py @@ -229,7 +229,7 @@ def checkInput(self): if self.inChoosingLevel: self.inChoosingLevel = False self.dashboard.state = "start" - self.dashboard.time = 0 + self.dashboard.time = 120 self.level.loadLevel(self.levelNames[self.currSelectedLevel-1]) self.dashboard.levelName = self.levelNames[self.currSelectedLevel-1].split("Level")[1] self.start = True diff --git a/main.py b/main.py index 9a2aba34..2b1c898f 100644 --- a/main.py +++ b/main.py @@ -35,6 +35,8 @@ def main(): mario.update() pygame.display.update() clock.tick(max_frame_rate) + if dashboard.time == 0: + mario.gameOver() return 'restart'