Game is working. Just need to add mor neat stuff to the storm-games module.
This commit is contained in:
parent
dccdfc988d
commit
b2ad5fd755
@ -9,6 +9,7 @@ sounds = initialize_gui("Numnastics")
|
||||
|
||||
def game(mode):
|
||||
i = 0
|
||||
startTime = time.time()
|
||||
tries = 0
|
||||
numberList = list("123456789")
|
||||
random.shuffle(numberList)
|
||||
@ -45,25 +46,19 @@ def game(mode):
|
||||
else:
|
||||
i = -1
|
||||
sounds['error'].play()
|
||||
endTime = round(time.time() - startTime, 2)
|
||||
message = [
|
||||
"Congratulations! You beat Numnastics in " + str(tries) + " tries.",\
|
||||
"Your time was " + str(endTime) + " seconds."]
|
||||
display_message(message)
|
||||
sounds['win'].play()
|
||||
speak("solved in " + str(tries) + " tries.")
|
||||
time.sleep(sounds['win'].get_length())
|
||||
return "menu"
|
||||
|
||||
# Game starts at main menu
|
||||
mode = game_menu("start game", "instructions", "credits", "exit_game")
|
||||
while True:
|
||||
try:
|
||||
if event.type == pygame.KEYDOWN:
|
||||
# Escape is the back/exit key, close the game if not playing, or return to menu if playing.
|
||||
if event.key == pygame.K_ESCAPE:
|
||||
if mode != "menu": mode = "menu"
|
||||
if mode == "menu": exit_game()
|
||||
# Call the game menu, if needed.
|
||||
if mode == "menu": mode = game_menu("start game", "instructions", "credits", "exit_game")
|
||||
if mode == "start game": mode = game(mode)
|
||||
except:
|
||||
pass
|
||||
# wait for an event
|
||||
event = pygame.event.wait()
|
||||
if mode == "menu": mode = game_menu("start game", "instructions", "credits", "exit_game")
|
||||
if mode == "start game": mode = game(mode)
|
||||
time.sleep(.001)
|
||||
|
||||
|
@ -47,6 +47,23 @@ def initialize_gui(gameTitle):
|
||||
time.sleep(soundData['game-intro'].get_length())
|
||||
return soundData
|
||||
|
||||
def display_message(info):
|
||||
info.append("Press escape or enter to continue.")
|
||||
info.reverse()
|
||||
info.append("Use the up and down arrow keys to navigate this message.")
|
||||
info.reverse()
|
||||
i = 0
|
||||
speak(str(info[0:len(info)]))
|
||||
while True:
|
||||
event = pygame.event.wait()
|
||||
if event.type == pygame.KEYDOWN:
|
||||
if event.key == pygame.K_ESCAPE or event.key == pygame.K_RETURN: return
|
||||
if event.key == pygame.K_DOWN and i < len(info) - 1: i = i + 1
|
||||
if event.key == pygame.K_UP and i > 0: i = i - 1
|
||||
speak(info[i])
|
||||
event = pygame.event.clear()
|
||||
time.sleep(0.001)
|
||||
|
||||
def instructions():
|
||||
info = (
|
||||
"Welcome to " + gameName + ": brought to you by Storm Dragon. Use the up and down arrows to navigate these instructions.",\
|
||||
|
Loading…
Reference in New Issue
Block a user