Close the inventory using the same key

This commit is contained in:
Yohann D'ANELLO 2020-12-04 14:57:53 +01:00
parent 067570fd1a
commit cdd527a7fd

View File

@ -83,6 +83,8 @@ class Game:
if self.state == GameMode.PLAY:
self.handle_key_pressed_play(key)
elif self.state == GameMode.INVENTORY:
self.handle_key_pressed_inventory(key)
elif self.state == GameMode.MAINMENU:
self.handle_key_pressed_main_menu(key)
elif self.state == GameMode.SETTINGS:
@ -110,6 +112,13 @@ class Game:
elif key == KeyValues.SPACE:
self.state = GameMode.MAINMENU
def handle_key_pressed_inventory(self, key: KeyValues) -> None:
"""
In the inventory menu, we can interact with items or close the menu.
"""
if key == KeyValues.SPACE or key == KeyValues.INVENTORY:
self.state = GameMode.PLAY
def handle_key_pressed_main_menu(self, key: KeyValues) -> None:
"""
In the main menu, we can navigate through options.