Added donate option. Got rid of the error that happened on exit.

This commit is contained in:
Storm Dragon 2019-11-26 18:42:07 -05:00
parent 3d956ccf47
commit 8a1471f648
2 changed files with 15 additions and 6 deletions

View File

@ -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)

View File

@ -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"