diff --git a/overcooked_simulator/gui_2d_vis/overcooked_gui.py b/overcooked_simulator/gui_2d_vis/overcooked_gui.py index 9b1919276f25dea76440a241f57ccccb92210f10..6240f4d9706d96ad9eedab4c3deaf927718eb1c1 100644 --- a/overcooked_simulator/gui_2d_vis/overcooked_gui.py +++ b/overcooked_simulator/gui_2d_vis/overcooked_gui.py @@ -559,6 +559,10 @@ class PyGameGUI: score = state["score"] self.score_label.set_text(f"Score {score}") + def update_conclusion_label(self, state): + score = state["score"] + self.conclusion_label.set_text(f"Your final score is {score}. Hurray!") + def update_remaining_time(self, remaining_time: timedelta): hours, rem = divmod(remaining_time.seconds, 3600) minutes, seconds = divmod(rem, 60) @@ -747,9 +751,9 @@ class PyGameGUI: self.conclusion_label = pygame_gui.elements.UILabel( text="Your final score was _", - relative_rect=pygame.Rect(0, 0, self.screen_margin, self.screen_margin), + relative_rect=pygame.Rect(0, 0, self.window_width, self.window_height), manager=self.manager, - object_id="#conclusion_label", + object_id="#score_label", ) def set_window_size(self, window_width, window_height, game_width, game_height): @@ -915,6 +919,7 @@ class PyGameGUI: match self.menu_state: case MenuStates.Start: pass + case MenuStates.Game: self.draw_background() @@ -923,19 +928,20 @@ class PyGameGUI: if state["ended"]: self.finished_button_press() self.manage_button_visibility() + else: + self.draw(state) - self.draw(state) - - game_screen_rect = self.game_screen.get_rect() - game_screen_rect.center = [ - self.window_width // 2, - self.window_height // 2, - ] + game_screen_rect = self.game_screen.get_rect() + game_screen_rect.center = [ + self.window_width // 2, + self.window_height // 2, + ] - self.main_window.blit(self.game_screen, game_screen_rect) + self.main_window.blit(self.game_screen, game_screen_rect) case MenuStates.End: - self.update_score_label(state) + self.update_conclusion_label(state) + self.manager.update(time_delta) pygame.display.flip()