More sounds added. Warning for edge of grave added, but it's not quite right yet.

This commit is contained in:
Storm Dragon
2025-01-31 03:23:54 -05:00
parent dfbccb97ad
commit fcc2dbf44a
9 changed files with 131 additions and 12 deletions

View File

@@ -139,23 +139,33 @@ class Level:
obj.xPos <= attackRange[1] and
self.player.isJumping): # Must be jumping to hit floating coffins
if obj.hit(self.player.xPos):
self.bouncing_items.append(obj.dropped_item)
speak(f"{obj.dropped_item.item_type} falls out!")
if obj.hit(self.player.xPos):
self.bouncing_items.append(obj.dropped_item)
speak(f"{obj.dropped_item.item_type} falls out!")
def handle_collisions(self):
for obj in self.objects:
if not obj.isActive:
continue
# Handle grave edge warnings
if obj.isHazard:
distance = abs(self.player.xPos - obj.xPos)
# Check if within 1 tile and moving
if distance <= 1 and not self.player.isJumping:
# Play edge warning sound (don't need to track the channel)
self.sounds['edge'].play()
if obj.is_in_range(self.player.xPos):
if obj.isCollectible and self.player.isJumping:
currentPos = round(self.player.xPos)
if currentPos not in obj.collectedPositions:
self.sounds[f'get_{obj.soundName}'].play()
speak(f"Collected {obj.soundName}")
obj.collect_at_position(currentPos)
self.player.collectedItems.append(obj.soundName)
if obj.soundName == "coin":
self.player._coins += 1
elif obj.isHazard and not self.player.isJumping:
self.sounds[obj.soundName].play()
speak("You fell in an open grave!")

View File

@@ -19,7 +19,7 @@ class Player:
# Inventory system
self.inventory = []
self.collectedItems = []
self.coins = 0
self._coins = 0
# Combat related attributes
self.weapons = []
@@ -103,6 +103,10 @@ class Player:
if self._lives > 0:
self._health = 10 # Reset health if we still have lives
def get_coins(self):
"""Get remaining coins"""
return self._coins
def get_lives(self):
"""Get remaining lives"""
return self._lives