Fixed cut_scene.

This commit is contained in:
Storm Dragon 2025-02-23 21:07:24 -05:00
parent a6702edf16
commit 998e319d92

View File

@ -8,9 +8,10 @@ Handles all audio functionality including:
"""
import os
import pyglet
import random
import re
import pyglet
import time
from os.path import isfile, join
from pyglet.window import key
@ -247,13 +248,19 @@ class Sound:
# Start playback
player.play()
# Wait for completion or skip using game's wait_for_completion method
# Make sure to give pyglet enough cycles to start playing
startTime = time.time()
duration = self.sounds[soundName].duration
pyglet.clock.tick()
# Wait for completion or skip
interrupted = self.game.wait_for_completion(
lambda: not player.playing
lambda: not player.playing or (time.time() - startTime) >= duration
)
# Ensure cleanup
player.pause()
if interrupted:
player.pause()
player.delete()
# Resume background music if it was playing