diff --git a/mine-racer/__pycache__/storm_games.cpython-35.pyc b/mine-racer/__pycache__/storm_games.cpython-35.pyc new file mode 100644 index 0000000..e599415 Binary files /dev/null and b/mine-racer/__pycache__/storm_games.cpython-35.pyc differ diff --git a/mine-racer/mine-racer.py b/mine-racer/mine-racer.py new file mode 100755 index 0000000..9cce713 --- /dev/null +++ b/mine-racer/mine-racer.py @@ -0,0 +1,23 @@ +#!/bin/python +# -*- coding: utf-8 -*- + +from storm_games import * + +# Initial variable settings +mode = "menu" +gameName = "Mine Racer" +sounds = initialize_gui(gameName) + +# loop forever (until a break occurs) +while True: + # wait for an event + event = pygame.event.wait() + # if the event is about a keyboard button that have been pressed... + 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", "credits", "exit") + time.sleep(.001) diff --git a/mine-racer/sounds/bottle.ogg b/mine-racer/sounds/bottle.ogg new file mode 100644 index 0000000..d107835 Binary files /dev/null and b/mine-racer/sounds/bottle.ogg differ diff --git a/mine-racer/sounds/empty.ogg b/mine-racer/sounds/empty.ogg new file mode 100644 index 0000000..a18f5be Binary files /dev/null and b/mine-racer/sounds/empty.ogg differ diff --git a/mine-racer/sounds/game-intro.ogg b/mine-racer/sounds/game-intro.ogg new file mode 100644 index 0000000..dc372e9 Binary files /dev/null and b/mine-racer/sounds/game-intro.ogg differ diff --git a/mine-racer/sounds/glass1.ogg b/mine-racer/sounds/glass1.ogg new file mode 100644 index 0000000..8a6a183 Binary files /dev/null and b/mine-racer/sounds/glass1.ogg differ diff --git a/mine-racer/sounds/glass2.ogg b/mine-racer/sounds/glass2.ogg new file mode 100644 index 0000000..5507c91 Binary files /dev/null and b/mine-racer/sounds/glass2.ogg differ diff --git a/mine-racer/sounds/glass3.ogg b/mine-racer/sounds/glass3.ogg new file mode 100644 index 0000000..8698ebf Binary files /dev/null and b/mine-racer/sounds/glass3.ogg differ diff --git a/mine-racer/sounds/gun1.ogg b/mine-racer/sounds/gun1.ogg new file mode 100644 index 0000000..b9fbf3e Binary files /dev/null and b/mine-racer/sounds/gun1.ogg differ diff --git a/mine-racer/sounds/gun2.ogg b/mine-racer/sounds/gun2.ogg new file mode 100644 index 0000000..41ca37d Binary files /dev/null and b/mine-racer/sounds/gun2.ogg differ diff --git a/mine-racer/sounds/gun3.ogg b/mine-racer/sounds/gun3.ogg new file mode 100644 index 0000000..87de4f1 Binary files /dev/null and b/mine-racer/sounds/gun3.ogg differ diff --git a/mine-racer/sounds/gun4.ogg b/mine-racer/sounds/gun4.ogg new file mode 100644 index 0000000..52953b3 Binary files /dev/null and b/mine-racer/sounds/gun4.ogg differ diff --git a/mine-racer/sounds/gun5.ogg b/mine-racer/sounds/gun5.ogg new file mode 100644 index 0000000..d05e1e1 Binary files /dev/null and b/mine-racer/sounds/gun5.ogg differ diff --git a/mine-racer/sounds/load3.ogg b/mine-racer/sounds/load3.ogg new file mode 100644 index 0000000..af7819c Binary files /dev/null and b/mine-racer/sounds/load3.ogg differ diff --git a/mine-racer/sounds/load4.ogg b/mine-racer/sounds/load4.ogg new file mode 100644 index 0000000..af7819c Binary files /dev/null and b/mine-racer/sounds/load4.ogg differ diff --git a/mine-racer/sounds/load5.ogg b/mine-racer/sounds/load5.ogg new file mode 100644 index 0000000..0ff00a4 Binary files /dev/null and b/mine-racer/sounds/load5.ogg differ diff --git a/mine-racer/storm_games.py b/mine-racer/storm_games.py new file mode 100755 index 0000000..aef6cbc --- /dev/null +++ b/mine-racer/storm_games.py @@ -0,0 +1,39 @@ +#!/bin/python +# -*- coding: utf-8 -*- +"""Standard initializations and functions shared by all games.""" + +import os +from os import listdir +from os.path import isfile, join +import pygame +import speechd +import time + +def __init__(): + spd = speechd.Client() + +def speak(text, interupt = True): + if interupt == True: spd.cancel() + spd.say(text) + +def exit_game(): + spd.close() + pygame.quit() + exit() + +def initialize_gui(gameTitle): + # start pygame + pygame.init() + # start the display (required by the event loop) + pygame.display.set_mode((320, 200)) + pygame.display.set_caption(gameTitle) + # Load sounds from the sound directory and creates a list like that {'bottle': 'bottle.ogg'} + soundFiles = [f for f in listdir("sounds/") if isfile(join("sounds/", f)) and (f.split('.')[1].lower() in ["ogg","wav"])] + #lets make a dict with pygame.mixer.Sound() objects {'bottle':} + soundData = {} + for f in soundFiles: + soundData[f.split('.')[0]] = pygame.mixer.Sound("sounds/" + f) + soundData['game-intro'].play() + time.sleep(soundData['game-intro'].get_length()) + return soundData +