diff --git a/mine-racer/mine-racer.py b/mine-racer/mine-racer.py index 26de60c..0430922 100755 --- a/mine-racer/mine-racer.py +++ b/mine-racer/mine-racer.py @@ -5,11 +5,22 @@ from storm_games import * # Initial variable settings mode = "menu" -gameName = "Mine Racer" -sounds = initialize_gui(gameName) +sounds = initialize_gui("Mine Racer") + +def game(): + pygame.mixer.music.load("sounds/music_car.ogg") + gameOver = False + jump = False + points = 0 + position = 0 + while not gameOver: + if pygame.mixer.music.get_busy() == 0 and jump == False: pygame.mixer.music.play(-1) + event = pygame.event.wait() + time.sleep(10) + exit_game() # Game starts at main menu -mode = game_menu("start game", "credits", "exit") +mode = game_menu("start game", "credits", "exit_game") while True: # wait for an event event = pygame.event.wait() @@ -20,5 +31,7 @@ while True: if mode != "menu": mode = "menu" if mode == "menu": exit_game() # Call the game menu, if needed. - if mode == "menu": mode = game_menu("start game", "credits", "exit") + if mode == "menu": mode = game_menu("start game", "credits", "exit_game") + if mode == "start game": game() time.sleep(.001) + diff --git a/mine-racer/storm_games.py b/mine-racer/storm_games.py index 1c64f8d..2a40851 100755 --- a/mine-racer/storm_games.py +++ b/mine-racer/storm_games.py @@ -49,25 +49,25 @@ def game_menu(*options): 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_RETURN: - if isfunction(options[i]): - speak(options[i] + "() is a function.") - options[i]() - else: - speak(options[i] + "() is not a function.") + try: + eval(options[i] + "()") + continue + except: return options[i] + continue speak(options[i]) event = pygame.event.clear() time.sleep(0.001) def credits(): - info = { - gameName + "brought to you by Storm Dragon",\ + info = ( + "Mine Racer: brought to you by Storm Dragon",\ "Billy Wolfe, designer and coder.",\ "http://stormdragon.tk",\ - "Press escape or enter to return to the game menu."} + "Press escape or enter to return to the game menu.") i = 0 speak(info[i]) - while loop == True: + while True: event = pygame.event.wait() if event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE or event.key == pygame.K_RETURN: return