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

Only use space to continue in menu

parent ca1454e8
No related branches found
No related tags found
1 merge request!62Resolve "Game Flow"
Pipeline #46935 passed
......@@ -8,7 +8,7 @@ from overcooked_simulator.utils import (
add_list_of_manager_ids_arguments,
)
USE_STUDY_SERVER = True
USE_STUDY_SERVER = False
def start_game_server(cli_args):
......
......@@ -5,7 +5,7 @@ plates:
# range of seconds until the dirty plate arrives.
game:
time_limit_seconds: 20
time_limit_seconds: 3
meals:
all: true
......
......@@ -5,7 +5,7 @@ plates:
# range of seconds until the dirty plate arrives.
game:
time_limit_seconds: 20
time_limit_seconds: 3
meals:
all: true
......
levels:
- config_path: environment_config.yaml
- config_path: study/environment_config.yaml
layout_path: overcooked-1/1-1-far-apart.layout
item_info_path: item_info.yaml
name: "Level 1-1: Far Apart"
# - config_path: environment_config.yaml
# layout_path: overcooked-1/1-4-bottleneck.layout
# item_info_path: item_info.yaml
# name: "Level 1-4: Bottleneck"
#
# - config_path: environment_config.yaml
# layout_path: overcooked-1/1-5-circle.layout
# item_info_path: item_info.yaml
# name: "Level 1-5: Circle"
- config_path: study/environment_config.yaml
layout_path: overcooked-1/1-4-bottleneck.layout
item_info_path: item_info.yaml
name: "Level 1-4: Bottleneck"
- config_path: study/environment_config.yaml
layout_path: overcooked-1/1-5-circle.layout
item_info_path: item_info.yaml
name: "Level 1-5: Circle"
- config_path: environment_config_dark.yaml
- config_path: study/environment_config_dark.yaml
layout_path: overcooked-1/4-2-dark.layout
item_info_path: item_info.yaml
name: "Level 4-2: Dark"
num_players: 2
num_players: 1
......@@ -1342,6 +1342,15 @@ class PyGameGUI:
# self.last_level = answer["last_level"]
# print("\nAT LAST LEVEL:", self.last_level, "\n")
def button_continue_postgame_pressed(self):
if not self.CONNECT_WITH_STUDY_SERVER:
self.current_layout_idx += 1
if self.current_layout_idx == len(self.layout_file_paths) - 1:
self.last_level = True
else:
log.debug(f"LEVEL: {self.layout_file_paths[self.current_layout_idx]}")
self.menu_state = MenuStates.PreGame
def manage_button_event(self, event):
if event.ui_element == self.quit_button:
self.running = False
......@@ -1438,15 +1447,7 @@ class PyGameGUI:
self.menu_state = MenuStates.PreGame
case self.next_game_button:
if not self.CONNECT_WITH_STUDY_SERVER:
self.current_layout_idx += 1
if self.current_layout_idx == len(self.layout_file_paths) - 1:
self.last_level = True
else:
log.debug(
f"LEVEL: {self.layout_file_paths[self.current_layout_idx]}"
)
self.menu_state = MenuStates.PreGame
self.button_continue_postgame_pressed()
case self.finish_study_button:
self.menu_state = MenuStates.End
......@@ -1508,16 +1509,25 @@ class PyGameGUI:
print("Number of joysticks:", pygame.joystick.get_count())
# Press key instead of mouse button press
if self.menu_state == MenuStates.Start:
if event.type in [pygame.JOYBUTTONDOWN, pygame.KEYDOWN]:
self.menu_state = MenuStates.ControllerTutorial
self.update_screen_elements()
elif self.menu_state == MenuStates.PreGame:
if event.type in [pygame.JOYBUTTONDOWN, pygame.KEYDOWN]:
self.setup_game()
self.set_game_size()
self.menu_state = MenuStates.Game
self.update_screen_elements()
if (
event.type in [pygame.JOYBUTTONDOWN, pygame.KEYDOWN]
and event.key == pygame.K_SPACE
):
match self.menu_state:
case MenuStates.Start:
self.menu_state = MenuStates.ControllerTutorial
self.update_screen_elements()
case MenuStates.PreGame:
self.setup_game()
self.set_game_size()
self.menu_state = MenuStates.Game
self.update_screen_elements()
case MenuStates.PostGame:
if self.last_level:
self.menu_state = MenuStates.End
else:
self.button_continue_postgame_pressed()
self.update_screen_elements()
if event.type == pygame_gui.UI_BUTTON_PRESSED:
self.manage_button_event(event)
......
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