1
0
forked from ndyer/pygame-dvd

added the ability to quit by pressing esc.

This commit is contained in:
Nicholas Dyer 2025-01-06 23:12:14 -05:00
parent afe58c15a8
commit 2957bb867f
Signed by: ndyer
GPG Key ID: B4FEDEE7298D2503

View File

@ -197,6 +197,11 @@ class Surface(pygame.Surface):
# Stop the game when a user clicks anywhere on the screen. # Stop the game when a user clicks anywhere on the screen.
self.running = False self.running = False
self.quit = True self.quit = True
case pygame.KEYDOWN:
if event.key == pygame.K_ESCAPE:
# Also stop the game if the Escape key is pressed.
self.running = False
self.quit = True
# Update positions and speeds of all sprites (in this case, just one logo sprite). # Update positions and speeds of all sprites (in this case, just one logo sprite).
self.all_sprites.update() self.all_sprites.update()