From df7945e3b6db308dc112645b74863e0e63174071 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Wed, 5 Mar 2025 19:39:08 -0500 Subject: [PATCH] Try to fix the problem with cut scenes sometimes not playing in the correct position and at the correct volume. --- __init__.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/__init__.py b/__init__.py index a3e63b8..6664f8e 100755 --- a/__init__.py +++ b/__init__.py @@ -681,13 +681,24 @@ def cut_scene(sounds, soundName): """ pygame.event.clear() pygame.mixer.stop() + + # Get the reserved channel (0) for cut scenes channel = pygame.mixer.Channel(0) + + # Apply the appropriate volume settings + # Use sfxVolume since cut scenes are sound effects + # Multiply by masterVolume for global volume control + channel.set_volume(sfxVolume * masterVolume, sfxVolume * masterVolume) + + # Play the sound channel.play(sounds[soundName]) + while pygame.mixer.get_busy(): - event = pygame.event.poll() - if event.type == pygame.KEYDOWN and event.key in [pygame.K_ESCAPE, pygame.K_RETURN, pygame.K_SPACE]: - pygame.mixer.stop() - pygame.event.pump() + for event in pygame.event.get(): + if event.type == pygame.KEYDOWN and event.key in [pygame.K_ESCAPE, pygame.K_RETURN, pygame.K_SPACE]: + pygame.mixer.stop() + return + pygame.time.delay(10) def play_random_falling(sounds, soundName, player_x, object_x, start_y, currentY=0, max_y=20, existing_channel=None):