From 551289aa0d40b80e8c2f8e6e732dbfc8b03e5e96 Mon Sep 17 00:00:00 2001 From: Viljami Ilola <+@hix.fi> Date: Sun, 31 Mar 2024 13:56:46 +0300 Subject: mainloop --- src/sliceitoff/game/game.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'src/sliceitoff/game') diff --git a/src/sliceitoff/game/game.py b/src/sliceitoff/game/game.py index 18c47b2..fea5151 100644 --- a/src/sliceitoff/game/game.py +++ b/src/sliceitoff/game/game.py @@ -11,7 +11,7 @@ from text import Fonts from stats import Stats from screens import welcome_screen, hiscores_screen from hiscores import HiScores -from mainmenu import Mainmenu +from mainmenu import Mainmenu, MenuItems from .level import Level from .show import Show @@ -73,10 +73,17 @@ class Game: return menu.selection def run(self): - """ This is the main loop of the game (not loop at the moment) """ - self.mainmenu() - self.welcome() - self.newgame() - if self.hiscores.high_enough(self.stats.score): - self.hiscores.add( self.stats.score, self.initials()) - self.show_highscores() + """ This is the main loop of the game """ + while True: + match self.mainmenu(): + case MenuItems.QUIT: + break + case MenuItems.HISCORES: + self.show_highscores() + case MenuItems.INSTRUCT: + self.welcome() + case MenuItems.NEWGAME: + self.newgame() + if self.hiscores.high_enough(self.stats.score): + self.hiscores.add( self.stats.score, self.initials()) + self.show_highscores() -- cgit v1.2.3