Compare commits

...

5 Commits

Author SHA1 Message Date
Storm Dragon
2f791da5b7 One more addition to pause. 2025-02-16 17:23:19 -05:00
Storm Dragon
9997b684ca Infinite loops are bad. 2025-02-16 17:19:47 -05:00
Storm Dragon
e7caff3d0f Fixed a bug with pause game. 2025-02-16 17:04:59 -05:00
Storm Dragon
db6c34f714 Improved pause_game. 2025-02-16 17:02:33 -05:00
Storm Dragon
3862b36d56 Pause game function added. 2025-02-16 16:52:29 -05:00

View File

@@ -315,6 +315,36 @@ def play_bgm(music_file):
except Exception as e: except Exception as e:
pass pass
def pause_game():
"""Pauses the game"""
speak("Game paused, press backspace to resume.")
pygame.event.clear()
try:
pygame.mixer.pause()
except:
pass
try:
pygame.mixer.music.pause()
except:
pass
while True:
event = pygame.event.wait()
if event.type == pygame.KEYDOWN and event.key == pygame.K_BACKSPACE: break
try:
pygame.mixer.unpause()
except:
pass
try:
pygame.mixer.music.unpause()
except:
pass
pygame.event.pump()
def get_input(prompt="Enter text:", text=""): def get_input(prompt="Enter text:", text=""):
"""Display a dialog box for text input. """Display a dialog box for text input.