|
|
|
|
@ -7,6 +7,7 @@ from PIL import Image
|
|
|
|
|
|
|
|
|
|
class GameWindow: |
|
|
|
|
def __init__(self, width, height, cell_size, title="Default", key_callback=None): |
|
|
|
|
os.environ["SDL_VIDEODRIVER"] = "x11" |
|
|
|
|
self.cell_size = cell_size |
|
|
|
|
self.width = width * cell_size |
|
|
|
|
self.height = height * cell_size |
|
|
|
|
@ -25,8 +26,8 @@ class GameWindow:
|
|
|
|
|
self.delay = 30 |
|
|
|
|
sdl2.ext.init(joystick=True, audio=True) |
|
|
|
|
self.load_joystick() |
|
|
|
|
# sdl2.SDL_Init(sdl2.SDL_INIT_AUDIO) |
|
|
|
|
# sdl2.sdlmixer.Mix_OpenAudio(44100, sdl2.sdlmixer.MIX_DEFAULT_FORMAT, 2, 2048) |
|
|
|
|
sdl2.SDL_Init(sdl2.SDL_INIT_AUDIO) |
|
|
|
|
sdl2.sdlmixer.Mix_OpenAudio(44100, sdl2.sdlmixer.MIX_DEFAULT_FORMAT, 2, 2048) |
|
|
|
|
self.window = sdl2.ext.Window(title=title, size=self.target_size,)# flags=sdl2.SDL_WINDOW_FULLSCREEN) |
|
|
|
|
self.window.show() |
|
|
|
|
self.renderer = sdl2.ext.Renderer(self.window, flags=sdl2.SDL_RENDERER_ACCELERATED) |
|
|
|
|
@ -168,7 +169,6 @@ class GameWindow:
|
|
|
|
|
self.h_offset = y |
|
|
|
|
|
|
|
|
|
def play_sound(self, sound_file): |
|
|
|
|
return |
|
|
|
|
sample = sdl2.sdlmixer.Mix_LoadWAV(byteify(sound_file, "utf-8")) |
|
|
|
|
if sample is None: |
|
|
|
|
raise RuntimeError("Cannot open audio file: {}".format(sdl2.sdlmixer.Mix_GetError())) |
|
|
|
|
|