mirror of
https://github.com/BreizhHardware/project_sanic.git
synced 2026-01-18 16:47:25 +01:00
Merge pull request #35 from BreizhHardware/dev_felix
Fix(Player) - Initialize pygame mixer for sound handling; add error h…
This commit is contained in:
@@ -83,6 +83,9 @@ class Player(Entity):
|
||||
self.attack_start_time = 0
|
||||
self.attack_cooldown = 2000
|
||||
|
||||
# Initialize 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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user