Try to fix the problem with cut scenes sometimes not playing in the correct position and at the correct volume.

This commit is contained in:
Storm Dragon 2025-03-05 19:39:08 -05:00
parent 7902dfacd1
commit df7945e3b6

View File

@ -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):