diff --git a/cooperative_cuisine/pygame_2d_vis/gui.py b/cooperative_cuisine/pygame_2d_vis/gui.py index df472228b29051133df2872bc8b1b28db9d3d767..0b4e18cb69d268c6a7a80cc0a0060ff53cb7924d 100644 --- a/cooperative_cuisine/pygame_2d_vis/gui.py +++ b/cooperative_cuisine/pygame_2d_vis/gui.py @@ -203,6 +203,10 @@ class PyGameGUI: self.images_path = ROOT_DIR / "pygame_gui" / "images" self.vis = Visualizer(self.visualization_config) + self.last_score: float = 0 + self.switch_score_color: bool = False + self.count_frames_score_label: int = 0 + self.fullscreen = False if self.show_debug_elements else True self.menu_state = MenuStates.Start @@ -1425,6 +1429,30 @@ class PyGameGUI: "translations.score", text_kwargs={"score": str(score)} ) + if self.switch_score_color: + self.count_frames_score_label += 1 + + duration_color_change = 30 + if score > self.last_score: + self.score_label.update_theming('{"colours": {"normal_text": "#00FF00"}}') + self.count_frames_score_label = 0 + self.switch_score_color = True + print("do once?") + elif score < self.last_score: + self.score_label.update_theming('{"colours": {"normal_text": "#FF0000"}}') + self.count_frames_score_label = 0 + self.switch_score_color = True + print("do once?1") + else: + if self.count_frames_score_label >= duration_color_change: + self.score_label.update_theming( + '{"colours": {"normal_text": "#000000"}}' + ) + self.count_frames_score_label = 0 + self.switch_score_color = False + + self.last_score = score + def update_remaining_time(self, remaining_time: float): """Updates the remaining time label. @@ -1472,7 +1500,7 @@ class PyGameGUI: environment_config=environment_config, layout_config=layout, seed=seed, - env_name=layout_path.stem + env_name=layout_path.stem, ).model_dump(mode="json") # print(CreateEnvironmentConfig.model_validate_json(json_data=creation_json))