Somewhat of a start on switching over to pyglet. It's in a very broken state with some remaining calls to pygame.

This commit is contained in:
Storm Dragon 2022-03-27 00:59:07 -04:00
parent 155ed6ec39
commit 639198e8de

View File

@ -10,7 +10,7 @@ from os.path import isfile, join
from inspect import isfunction
from xdg import BaseDirectory
from setproctitle import setproctitle
import pygame
import pyglet
import pyperclip
import random
import re
@ -125,9 +125,8 @@ def speak(text, interupt = True):
def exit_game():
if speechProvider == "speechd": spd.close()
pygame.mixer.music.stop()
pygame.quit()
exit()
# Close the pyglet window
pyglet.app.exit()
def initialize_gui(gameTitle):
# Check for, and possibly create, storm-games path
@ -142,24 +141,16 @@ def initialize_gui(gameTitle):
global gameName
gameName = gameTitle
setproctitle(str.lower(str.replace(gameTitle, " ", "")))
# start pygame
pygame.init()
# start the display (required by the event loop)
pygame.display.set_mode((320, 200))
pygame.display.set_caption(gameTitle)
# Set 32 channels for sound by default
pygame.mixer.init()
pygame.mixer.set_num_channels(32)
# Reserve the cut scene channel
pygame.mixer.set_reserved(0)
# Load sounds from the sound directory and creates a list like that {'bottle': 'bottle.ogg'}
# init pyglet window
window = pyglet.window.Window(500, 300, gameTitle)
# Load sounds from the sound directory and creates a list like {'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>}
# make a dict with pyglet media {'bottle':<soundobject>}
soundData = {}
for f in soundFiles:
soundData[f.split('.')[0]] = pygame.mixer.Sound("sounds/" + f)
soundData[f.split('.')[0]] = pyglet.media.load("sounds/" + f, streaming = False)
soundData['game-intro'].play()
time.sleep(soundData['game-intro'].get_length())
time.sleep(soundData['game-intro'].duration)
return soundData
def cut_scene(sounds, soundName):