Added sound for when pumpkin hits you or lands near by.

This commit is contained in:
Storm Dragon
2025-02-01 02:57:01 -05:00
parent 7627543ed8
commit 3836f4a2c9
2 changed files with 13 additions and 4 deletions

BIN
sounds/pumpkin_splat.ogg (Stored with Git LFS) Normal file

Binary file not shown.

View File

@@ -29,11 +29,17 @@ class Pumpkin:
return True return True
def stop_sound(self): def stop_sound(self, sounds, playerX):
"""Stop the pumpkin's sound""" """Stop the pumpkin's sound and play splat if needed"""
if self.soundChannel: if self.soundChannel:
obj_stop(self.soundChannel) obj_stop(self.soundChannel)
self.soundChannel = None self.soundChannel = None
# Calculate volume and pan for splat sound based on final position
volume, left, right = calculate_volume_and_pan(playerX, self.x)
if volume > 0: # Only play if within audible range
channel = sounds["pumpkin_splat"].play()
if channel:
channel.set_volume(volume * left, volume * right)
def check_collision(self, player): def check_collision(self, player):
"""Check if pumpkin hits player""" """Check if pumpkin hits player"""
@@ -125,13 +131,13 @@ class Catapult(Object):
# Always update existing pumpkins # Always update existing pumpkins
for pumpkin in self.activePumpkins[:]: # Copy list to allow removal for pumpkin in self.activePumpkins[:]: # Copy list to allow removal
if not pumpkin.update(self.sounds, player.xPos): if not pumpkin.update(self.sounds, player.xPos):
pumpkin.stop_sound() pumpkin.stop_sound(self.sounds, player.xPos)
self.activePumpkins.remove(pumpkin) self.activePumpkins.remove(pumpkin)
continue continue
if pumpkin.check_collision(player): if pumpkin.check_collision(player):
player.set_health(player.get_health() - pumpkin.damage) player.set_health(player.get_health() - pumpkin.damage)
pumpkin.stop_sound() pumpkin.stop_sound(self.sounds, player.xPos)
pumpkin.isActive = False pumpkin.isActive = False
self.activePumpkins.remove(pumpkin) self.activePumpkins.remove(pumpkin)
speak("Hit by a pumpkin!") speak("Hit by a pumpkin!")