From e3927524c7345fbbaa77406118b56435ba70d27a Mon Sep 17 00:00:00 2001 From: Skyball2000 Date: Wed, 29 Mar 2023 14:29:36 +0200 Subject: [PATCH] Fixed background images in level selection --- project/level/selection/LevelScreenManager.py | 2 +- project/main.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/project/level/selection/LevelScreenManager.py b/project/level/selection/LevelScreenManager.py index d7ba526..2c473f7 100644 --- a/project/level/selection/LevelScreenManager.py +++ b/project/level/selection/LevelScreenManager.py @@ -27,4 +27,4 @@ class LevelScreenManager(ScreenManager): def tick(self, tick_data: TickData): if tick_data.key_manager.is_keymap_down(KeyManager.KEY_ESCAPE): - self.main_loop.select_level_selection() + self.main_loop.select_level_selection(self.level.theme) diff --git a/project/main.py b/project/main.py index 2b37fc9..03ffede 100644 --- a/project/main.py +++ b/project/main.py @@ -92,8 +92,10 @@ class MainLoop: self.level = level self.set_game_state(self.GAME_STATE_LEVEL) - def select_level_selection(self): + def select_level_selection(self, theme: str = 'tutorial'): self.set_game_state(self.GAME_STATE_LEVEL_SELECTION) + if self.screen_manager is not None and isinstance(self.screen_manager, LevelSelectionScreenManager): + self.screen_manager.select_theme(theme) def set_game_state(self, game_state: str): self.game_state = game_state @@ -148,7 +150,7 @@ class MainLoop: self.screen_manager.tick(tick_data) self.sprite_manager.tick(tick_data) - if self.level is not None: + if self.level is not None and self.game_state == self.GAME_STATE_LEVEL: self.screen.blit(BACKGROUND_IMAGES_SCALED[self.level.theme], (0, 0)) self.sprite_manager.draw(self.screen, self.screen_transform)