Skip to content

Commit

Permalink
Escape now consumed in events
Browse files Browse the repository at this point in the history
  • Loading branch information
MegatronJeremy committed Aug 25, 2024
1 parent b265d8d commit 248fbf3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/gui/display_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,12 @@ def __start_the_game(self, game_type: GameType, is_full: bool, use_advanced_ai:
def __check_events(self) -> list[pygame.event.Event]:
events = pygame.event.get()
for event in events:
if event.type == pygame.QUIT or event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
if event.type == pygame.QUIT or (event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE):
# set the game end
if self.__game:
self.__game.over.set()
if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
events.remove(event) # Consume ESCAPE event to avoid menus bugging out
if event.type == pygame.QUIT:
self.__running = False
if self.__game and self.__game.is_archived:
Expand Down

0 comments on commit 248fbf3

Please sign in to comment.