From 7c4648f815cee7e3641a048895a8011f30c48ca8 Mon Sep 17 00:00:00 2001 From: fheinrich <fheinrich@techfak.uni-bielefeld.de> Date: Fri, 15 Dec 2023 16:44:44 +0100 Subject: [PATCH] Cleaned visualization up. --- .../game_content/item_info.yaml | 2 +- overcooked_simulator/pygame_gui/pygame_gui.py | 33 +++---------------- .../pygame_gui/visualization.yaml | 18 ---------- 3 files changed, 6 insertions(+), 47 deletions(-) diff --git a/overcooked_simulator/game_content/item_info.yaml b/overcooked_simulator/game_content/item_info.yaml index 8f54e8e0..3216c8ba 100644 --- a/overcooked_simulator/game_content/item_info.yaml +++ b/overcooked_simulator/game_content/item_info.yaml @@ -24,7 +24,7 @@ TomatoSoup: type: Meal finished_progress_name: TomatoSoup steps_needed: 500 - needs: [ Tomato, Tomato, Tomato , Tomato, Tomato, Tomato, Tomato, Tomato, Tomato, Tomato, Tomato , Tomato, Tomato, Tomato, Tomato, Tomato, Tomato, Tomato, Tomato , Tomato, Tomato, Tomato, Tomato, Tomato, Tomato ] + needs: [ Tomato, Tomato, Tomato ] equipment: Pot Plate: diff --git a/overcooked_simulator/pygame_gui/pygame_gui.py b/overcooked_simulator/pygame_gui/pygame_gui.py index 01999b3e..06310948 100644 --- a/overcooked_simulator/pygame_gui/pygame_gui.py +++ b/overcooked_simulator/pygame_gui/pygame_gui.py @@ -27,7 +27,7 @@ def create_polygon(n, length): if n == 0: return np.array([0, 0]) - vector = np.array([0, length]) + vector = np.array([length, 0]) angle = (2 * np.pi) / n rot_matrix = np.array( @@ -304,39 +304,16 @@ class PyGameGUI: if isinstance(item, ProgressibleItem) and not item.finished: self.draw_progress_bar(pos, item.progressed_steps, item.steps_needed) - # if isinstance(item, Plate) and item.holds: - # self.draw_item(pos, item.holds) - if isinstance(item, CookingEquipment) and item.content: self.draw_item(pos, item.content) if isinstance(item, Meal): - if "Soup" in item.name: - if item.finished: - if item.name in self.visualization_config: - image = pygame.image.load( - ROOT_DIR - / "pygame_gui" - / self.visualization_config[item.name]["parts"][0]["path"] - ).convert_alpha() - - size = self.visualization_config[item.name]["parts"][0]["size"] - image = pygame.transform.scale( - image, (size * scale, size * scale) - ) - - rect = image.get_rect() - rect.center = pos - self.screen.blit(image, rect) - elif item.parts: - triangle_offsets = create_polygon(len(item.parts), length=25) - print(triangle_offsets) - for idx, item in enumerate(item.parts): - self.draw_item(pos + triangle_offsets[idx], item, scale=0.6) - + if item.finished: + if item.name in self.visualization_config: + self.draw_thing(pos, self.visualization_config[item.name]["parts"]) else: for idx, o in enumerate(item.parts): - triangle_offsets = create_polygon(len(item.parts), length=25) + triangle_offsets = create_polygon(len(item.parts), length=10) self.draw_item(pos + triangle_offsets[idx], o, scale=0.6) def draw_progress_bar(self, pos, current, needed): diff --git a/overcooked_simulator/pygame_gui/visualization.yaml b/overcooked_simulator/pygame_gui/visualization.yaml index 54fe70b4..7f05d529 100644 --- a/overcooked_simulator/pygame_gui/visualization.yaml +++ b/overcooked_simulator/pygame_gui/visualization.yaml @@ -115,24 +115,6 @@ ChoppedTomato: path: images/tomato_cut.png size: 40 -TomatoSoup1of3: - parts: - - type: circle - radius: 4 - color: firebrick - -TomatoSoup2of3: - parts: - - type: circle - radius: 8 - color: firebrick - -TomatoSoup3of3: - parts: - - type: circle - radius: 12 - color: firebrick - TomatoSoup: parts: - type: image -- GitLab