diff --git a/overcooked_simulator/gui_2d_vis/drawing.py b/overcooked_simulator/gui_2d_vis/drawing.py index ab6f706063a63b6e5c2368c63ae60f070543af00..c907874b44e5ec467851211f2df6c0863f867ea6 100644 --- a/overcooked_simulator/gui_2d_vis/drawing.py +++ b/overcooked_simulator/gui_2d_vis/drawing.py @@ -92,13 +92,36 @@ class Visualizer: ) if "view_restriction" in state and state["view_restriction"]: - direction = np.array(state["view_restriction"][0]) - pos = np.array(state["view_restriction"][1]) - angel = state["view_restriction"][2] - # rotate direction vector in both direction with the angel # draw 2 large rect which are rotated so that one edge is the viewing border + direction = pygame.math.Vector2(state["view_restriction"][0]) + pos = pygame.math.Vector2(state["view_restriction"][1]) + angle = state["view_restriction"][2] + + pos = pos * grid_size + pygame.math.Vector2([grid_size / 2, grid_size / 2]) + + rect_scale = max(width, height) + + left_beam = pos + (direction.rotate(angle) * rect_scale * 2) + right_beam = pos + (direction.rotate(-angle) * rect_scale * 2) + + pygame.draw.polygon( + screen, + colors["black"], + ( + pos - (direction * grid_size * 0.8), + left_beam, + pos + - (direction * rect_scale * 2) + + (direction.rotate(90) * rect_scale), + pos + - (direction * rect_scale * 2) + + (direction.rotate(-90) * rect_scale), + right_beam, + ), + ) + def draw_background(self, surface, width, height, grid_size): """Visualizes a game background.""" block_size = grid_size // 2 # Set the size of the grid block