> > > > A second solution is to load the sounds in the background of the game, > especially if you're going to launch on a menu where the sounds won't be > needed. You can pre-populate a dictionary with dummy sounds and use a > thread to go through and load each sound into the dictionary while the user > interacts with the menu. > > SOUND_PATH_MAPPING = {'horn_funny': 'horn_funny.ogg', 'horn_sad': > 'extra_sounds/horn_sad.wav'} > > SOUNDS = {name: None for name in SOUND_PATH_MAPPING} > > def load_sounds(): > > for name, path in SOUND_PATH_MAPPING: > > SOUNDS[name] = pygame.mixer.Sound(path) > > > def load_sounds_background(): > > thread.start_new_thread(load_sounds, ()) > > >
There's no menus, it just loads and waits for the user to trigger sounds on a keypad. I could play a single sound while the other sounds are loading, but I'd prefer to have it fully functional at startup if possible.