From 8a1471f64818c3f6a26511f8a3ce30e530c2e178 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Tue, 26 Nov 2019 18:42:07 -0500 Subject: [PATCH] Added donate option. Got rid of the error that happened on exit. --- numnastics | 4 ++-- storm_games.py | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/numnastics b/numnastics index 5e07969..070581d 100755 --- a/numnastics +++ b/numnastics @@ -56,8 +56,8 @@ def game(mode): return "menu" # Game starts at main menu -mode = game_menu("start game", "instructions", "credits", "exit_game") -while True: +mode = game_menu("start game", "instructions", "donate", "credits", "exit_game") +while mode != "exit_game": if mode == "menu": mode = game_menu("start game", "instructions", "credits", "exit_game") if mode == "start game": mode = game(mode) time.sleep(.001) diff --git a/storm_games.py b/storm_games.py index 897be82..6835991 100755 --- a/storm_games.py +++ b/storm_games.py @@ -32,6 +32,7 @@ def speak(text, interupt = True): def exit_game(): spd.close() + pygame.mixer.music.stop() pygame.quit() exit() @@ -132,17 +133,25 @@ def game_menu(*options): event = pygame.event.wait() if event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: exit_game() - if event.key == pygame.K_DOWN and i < len(options) - 1: i = i + 1 - if event.key == pygame.K_UP and i > 0: i = i - 1 + if event.key == pygame.K_DOWN and i < len(options) - 1: + i = i + 1 + pygame.mixer.music.unpause() + if event.key == pygame.K_UP and i > 0: + i = i - 1 + pygame.mixer.music.unpause() if event.key == pygame.K_RETURN: try: eval(options[i] + "()") continue except: - pygame.mixer.music.fadeout(500) - time.sleep(0.25) return options[i] continue speak(options[i]) event = pygame.event.clear() time.sleep(0.001) + +def donate(*mode): + import subprocess + subprocess.call(["xdg-open", "https://liberapay.com/stormdragon2976/donate"]) + pygame.mixer.music.pause() + mode = "menu"