More progress on menus.

This commit is contained in:
Storm dragon 2016-03-23 13:40:30 -04:00
parent 343a829e37
commit 870b8b39c0
2 changed files with 33 additions and 7 deletions

View File

@ -8,7 +8,8 @@ mode = "menu"
gameName = "Mine Racer" gameName = "Mine Racer"
sounds = initialize_gui(gameName) sounds = initialize_gui(gameName)
# loop forever (until a break occurs) # Game starts at main menu
mode = game_menu("start game", "credits", "exit")
while True: while True:
# wait for an event # wait for an event
event = pygame.event.wait() event = pygame.event.wait()

View File

@ -5,6 +5,7 @@
import os import os
from os import listdir from os import listdir
from os.path import isfile, join from os.path import isfile, join
from inspect import isfunction
import pygame import pygame
import speechd import speechd
import time import time
@ -43,12 +44,36 @@ def game_menu(*options):
speak(options[i]) speak(options[i])
while loop == True: while loop == True:
event = pygame.event.wait() event = pygame.event.wait()
if event.key == pygame.K_ESCAPE: exit_game() if event.type == pygame.KEYDOWN:
if event.key == pygame.K_DOWN and i < len(options) - 1: if event.key == pygame.K_ESCAPE: exit_game()
i = i + 1 if event.key == pygame.K_DOWN and i < len(options) - 1: i = i + 1
speak(options[i]) if event.key == pygame.K_UP and i > 0: i = i - 1
if event.key == pygame.K_UP and i > 0: if event.key == pygame.K_RETURN:
i = i - 1 if isfunction(options[i]):
speak(options[i] + "() is a function.")
options[i]()
else:
speak(options[i] + "() is not a function.")
return options[i]
speak(options[i]) speak(options[i])
event = pygame.event.clear() event = pygame.event.clear()
time.sleep(0.001) time.sleep(0.001)
def credits():
info = {
gameName + "brought to you by Storm Dragon",\
"Billy Wolfe, designer and coder.",\
"http://stormdragon.tk",\
"Press escape or enter to return to the game menu."}
i = 0
speak(info[i])
while loop == 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)