From 2fbeaaf4fbb5372415a989a9501cfe7e1ff21e24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20MARQUET?= <72651575+BreizhHardware@users.noreply.github.com> Date: Wed, 9 Apr 2025 14:07:35 +0200 Subject: [PATCH] Fix(Player) - Initialize pygame mixer for sound handling; add error handling for jump sound playback. --- src/Entity/Player.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Entity/Player.py b/src/Entity/Player.py index 691fa0a..d8ab94b 100644 --- a/src/Entity/Player.py +++ b/src/Entity/Player.py @@ -83,6 +83,9 @@ class Player(Entity): self.attack_start_time = 0 self.attack_cooldown = 2000 + # Initilize mixer + pygame.mixer.init() + def load_images(self): """Load images for the player""" try: @@ -295,8 +298,11 @@ class Player(Entity): # Jumping logic if jump and not self.jumping: - jump_sound = pygame.mixer.Sound("assets/sound/Jump.mp3") - jump_sound.play() + try: + jump_sound = pygame.mixer.Sound("assets/sound/Jump.mp3") + jump_sound.play() + except Exception as e: + print(f"Error playing jump sound: {e}") self.vel.y = -self.jump_power self.jumping = True