Skip to content
Snippets Groups Projects
Commit 750519e3 authored by Fabian Heinrich's avatar Fabian Heinrich
Browse files

Multiple Players can be controlled with a single set of keys by switching...

Multiple Players can be controlled with a single set of keys by switching through. Behavior of switching can be controlled in start menu.
parent 274592dd
No related branches found
No related tags found
1 merge request!44Resolve "GUI Player Management"
Pipeline #45181 passed
......@@ -67,9 +67,10 @@ class Visualizer:
def draw_gamescreen(
self,
screen,
state,
grid_size,
screen: pygame.Surface,
state: dict,
grid_size: int,
controlled_player_idxs: list[int],
):
width = int(np.ceil(state["kitchen"]["width"] * grid_size))
height = int(np.ceil(state["kitchen"]["height"] * grid_size))
......@@ -85,14 +86,20 @@ class Visualizer:
grid_size,
)
for idx, col in zip(controlled_player_idxs, [colors["blue"], colors["red"]]):
pygame.draw.circle(
screen,
col,
np.array(state["players"][idx]["pos"]) * grid_size + (grid_size // 2),
(grid_size / 2),
)
self.draw_players(
screen,
state["players"],
grid_size,
)
print(state)
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
......@@ -152,7 +159,7 @@ class Visualizer:
if USE_PLAYER_COOK_SPRITES:
pygame.draw.circle(
screen,
self.player_colors[p_idx],
colors[self.player_colors[p_idx]],
pos - facing * grid_size * 0.25,
grid_size * 0.2,
)
......
......@@ -92,5 +92,10 @@
"normal_border": "#000000",
"normal_text": "#000000"
}
},
"#players": {
"colours": {
"normal_bg": "#fffacd"
}
}
}
\ No newline at end of file
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment