create dict with filenames

This commit is contained in:
chrys 2016-03-20 23:37:39 +01:00
parent 73537ee635
commit f22cd5a191

View File

@ -8,13 +8,16 @@ from os.path import isfile, join
import pygame import pygame
import time import time
SoundFolder = 'sounds'
def initialize_gui(gameTitle): def initialize_gui(gameTitle):
# start pygame # start pygame
pygame.init() pygame.init()
# start the display (required by the event loop) # start the display (required by the event loop)
pygame.display.set_mode((320, 200)) pygame.display.set_mode((320, 200))
pygame.display.set_caption(gameTitle) pygame.display.set_caption(gameTitle)
# Load sounds from the sound directory # Load sounds from the sound directory and creates a dict like that {'bottle': 'bottle.ogg'}
onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))] soundFiles = {f.split('.')[0]:f for f in listdir(SoundFolder) if isfile(join(SoundFolder, f))}