Close the inventory using the same key
This commit is contained in:
parent
067570fd1a
commit
cdd527a7fd
|
@ -83,6 +83,8 @@ class Game:
|
||||||
|
|
||||||
if self.state == GameMode.PLAY:
|
if self.state == GameMode.PLAY:
|
||||||
self.handle_key_pressed_play(key)
|
self.handle_key_pressed_play(key)
|
||||||
|
elif self.state == GameMode.INVENTORY:
|
||||||
|
self.handle_key_pressed_inventory(key)
|
||||||
elif self.state == GameMode.MAINMENU:
|
elif self.state == GameMode.MAINMENU:
|
||||||
self.handle_key_pressed_main_menu(key)
|
self.handle_key_pressed_main_menu(key)
|
||||||
elif self.state == GameMode.SETTINGS:
|
elif self.state == GameMode.SETTINGS:
|
||||||
|
@ -110,6 +112,13 @@ class Game:
|
||||||
elif key == KeyValues.SPACE:
|
elif key == KeyValues.SPACE:
|
||||||
self.state = GameMode.MAINMENU
|
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:
|
def handle_key_pressed_main_menu(self, key: KeyValues) -> None:
|
||||||
"""
|
"""
|
||||||
In the main menu, we can navigate through options.
|
In the main menu, we can navigate through options.
|
||||||
|
|
Loading…
Reference in New Issue