Ok, I have actualy made progress on this game. So, initial commit of mine-racer.
This commit is contained in:
parent
b271242bc9
commit
7aec6306e5
BIN
mine-racer/__pycache__/storm_games.cpython-35.pyc
Normal file
BIN
mine-racer/__pycache__/storm_games.cpython-35.pyc
Normal file
Binary file not shown.
23
mine-racer/mine-racer.py
Executable file
23
mine-racer/mine-racer.py
Executable file
@ -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)
|
BIN
mine-racer/sounds/bottle.ogg
Normal file
BIN
mine-racer/sounds/bottle.ogg
Normal file
Binary file not shown.
BIN
mine-racer/sounds/empty.ogg
Normal file
BIN
mine-racer/sounds/empty.ogg
Normal file
Binary file not shown.
BIN
mine-racer/sounds/game-intro.ogg
Normal file
BIN
mine-racer/sounds/game-intro.ogg
Normal file
Binary file not shown.
BIN
mine-racer/sounds/glass1.ogg
Normal file
BIN
mine-racer/sounds/glass1.ogg
Normal file
Binary file not shown.
BIN
mine-racer/sounds/glass2.ogg
Normal file
BIN
mine-racer/sounds/glass2.ogg
Normal file
Binary file not shown.
BIN
mine-racer/sounds/glass3.ogg
Normal file
BIN
mine-racer/sounds/glass3.ogg
Normal file
Binary file not shown.
BIN
mine-racer/sounds/gun1.ogg
Normal file
BIN
mine-racer/sounds/gun1.ogg
Normal file
Binary file not shown.
BIN
mine-racer/sounds/gun2.ogg
Normal file
BIN
mine-racer/sounds/gun2.ogg
Normal file
Binary file not shown.
BIN
mine-racer/sounds/gun3.ogg
Normal file
BIN
mine-racer/sounds/gun3.ogg
Normal file
Binary file not shown.
BIN
mine-racer/sounds/gun4.ogg
Normal file
BIN
mine-racer/sounds/gun4.ogg
Normal file
Binary file not shown.
BIN
mine-racer/sounds/gun5.ogg
Normal file
BIN
mine-racer/sounds/gun5.ogg
Normal file
Binary file not shown.
BIN
mine-racer/sounds/load3.ogg
Normal file
BIN
mine-racer/sounds/load3.ogg
Normal file
Binary file not shown.
BIN
mine-racer/sounds/load4.ogg
Normal file
BIN
mine-racer/sounds/load4.ogg
Normal file
Binary file not shown.
BIN
mine-racer/sounds/load5.ogg
Normal file
BIN
mine-racer/sounds/load5.ogg
Normal file
Binary file not shown.
39
mine-racer/storm_games.py
Executable file
39
mine-racer/storm_games.py
Executable file
@ -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':<soundobject>}
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user