Added points system with scoreboard.

This commit is contained in:
Storm Dragon
2025-02-14 21:39:32 -05:00
parent 03b59256b2
commit 1d60c58532
7 changed files with 45 additions and 4 deletions

View File

@@ -29,6 +29,7 @@ class Level:
self.isLocked = levelData.get("locked", False) # Default to False if not specified
self.levelId = levelData["level_id"]
self.levelName = levelData.get("name", "Unnamed Level")
self.levelScore = 0
# Get footstep sound for this level, default to 'footstep' if not specified
self.footstepSound = levelData.get("footstep_sound", "footstep")
@@ -242,6 +243,7 @@ class Level:
if abs(item._currentX - self.player.xPos) < 1 and self.player.isJumping:
play_sound(self.sounds[f'get_{item.soundName}'])
item.apply_effect(self.player)
self.levelScore += 1000 # All items collected points awarded
item.isActive = False
self.bouncing_items.remove(item)
@@ -324,6 +326,7 @@ class Level:
self.player.stats.update_stat('Items collected', 1)
if obj.soundName == "coin":
self.player._coins += 1
self.levelScore += 100
self.player.stats.update_stat('Bone dust', 1)
if self.player._coins % 5 == 0:
# Only heal if below max health
@@ -337,6 +340,7 @@ class Level:
# Extra life
self.player._coins = 0
self.player._lives += 1
self.levelScore += 1000
play_sound(self.sounds['get_extra_life'])
continue
@@ -409,6 +413,9 @@ class Level:
# Level complete
pygame.mixer.stop()
play_sound(self.sounds['end_of_level'])
self.levelScore += 10000
# Actually update the scoreboard with level completion
self.player.scoreboard.increase_score(self.levelScore)
return True
return False