diff --git a/libstormgames b/libstormgames index 7cbbc64..c242fc6 160000 --- a/libstormgames +++ b/libstormgames @@ -1 +1 @@ -Subproject commit 7cbbc64d27fe533e27332371a332ffb298a82d3c +Subproject commit c242fc6832a6231ad56153e98fb8ee33e0105a69 diff --git a/src/coffin.py b/src/coffin.py index ef7a11a..2a97ffb 100644 --- a/src/coffin.py +++ b/src/coffin.py @@ -24,6 +24,7 @@ class CoffinObject(Object): if not self.isBroken: self.isBroken = True play_sound(self.sounds['coffin_shatter']) + self.level.levelScore += 500 self.level.player.stats.update_stat('Coffins broken', 1) # Stop the ongoing coffin sound diff --git a/src/enemy.py b/src/enemy.py index e506a07..fd15bc4 100644 --- a/src/enemy.py +++ b/src/enemy.py @@ -226,6 +226,17 @@ class Enemy(Object): if self.channel: obj_stop(self.channel) self.channel = None + + # Calculate and award points based on enemy stats + basePoints = self.health * 500 + damageModifier = self.damage * 750 + rangeModifier = self.attackRange * 250 + speedModifier = int(self.movementSpeed * 1000) + totalPoints = max(basePoints + damageModifier + rangeModifier + speedModifier, 1000) + + # Award points + self.level.levelScore += totalPoints + # Play death sound if available using positional audio deathSound = f"{self.enemyType}_dies" if deathSound in self.sounds: diff --git a/src/level.py b/src/level.py index 44da083..a74e8c7 100644 --- a/src/level.py +++ b/src/level.py @@ -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 diff --git a/src/player.py b/src/player.py index 6633a59..fb4b055 100644 --- a/src/player.py +++ b/src/player.py @@ -66,6 +66,8 @@ class Player: attackDuration=200 # 200ms attack duration )) + self.scoreboard = Scoreboard() + def should_play_footstep(self, currentTime): """Check if it's time to play a footstep sound""" return (self.distanceSinceLastStep >= self.get_step_distance() and diff --git a/src/powerup.py b/src/powerup.py index e3e0785..9574d63 100644 --- a/src/powerup.py +++ b/src/powerup.py @@ -108,5 +108,8 @@ class PowerUp(Object): nunchucksWeapon = Weapon.create_nunchucks() player.add_weapon(nunchucksWeapon) player.equip_weapon(nunchucksWeapon) + basePoints = nunchucksWeapon.damage * 1000 + rangeModifier = nunchucksWeapon.range * 500 + player.scoreboard.increase_score(basePoints + rangeModifier) play_sound(self.sounds['get_nunchucks']) player.stats.update_stat('Items collected', 1) diff --git a/wicked_quest.py b/wicked_quest.py index 9f40030..f437fb4 100644 --- a/wicked_quest.py +++ b/wicked_quest.py @@ -103,7 +103,7 @@ class WickedQuest: if keys[pygame.K_h]: speak(f"{player.get_health()} health of {player.get_max_health()}") if keys[pygame.K_i]: - speak(f"Level {self.currentLevel.levelId}, {self.currentLevel.levelName}. {player.get_health()} health of {player.get_max_health()}. {player.get_lives()} lives remaining.") + speak(f"Level {self.currentLevel.levelId}, {self.currentLevel.levelName}. {player.get_health()} health of {player.get_max_health()}. {self.currentLevel.levelScore} points on this level so far. {player.get_lives()} lives remaining.") if keys[pygame.K_l]: speak(f"{player.get_lives()} lives") if keys[pygame.K_j]: # Check jack o'lanterns @@ -150,6 +150,8 @@ class WickedQuest: if key != 'Total time': # Skip time since we already displayed it report.append(f"{key}: {self.currentLevel.player.stats.get_level_stat(key)}") + report.append(f"Score: {self.currentLevel.levelScore}") + # Stop all sounds and music then play fanfare try: speak(f"Level {self.currentLevel.levelId}, {self.currentLevel.levelName}, complete!") @@ -174,6 +176,11 @@ class WickedQuest: if key not in ['Total time', 'levelsCompleted']: # Skip these report.append(f"Total {key}: {self.currentLevel.player.stats.get_total_stat(key)}") + report.append(f"Final Score: {self.player.scoreboard.get_score()}") + + if self.player.scoreboard.check_high_score(): + self.player.scoreboard.add_high_score() + cut_scene(self.sounds, "game_over") display_text(report) @@ -269,8 +276,8 @@ class WickedQuest: pass while True: - choice = game_menu(self.sounds, "play", "instructions", "learn_sounds", - "credits", "donate", "exit") + choice = game_menu(self.sounds, "play", "high_scores", "instructions", + "learn_sounds", "credits", "donate", "exit") if choice == "exit": exit_game() @@ -281,6 +288,16 @@ class WickedQuest: self.gameStartTime = pygame.time.get_ticks() if self.load_level(1): self.game_loop() + elif choice == "high_scores": + board = Scoreboard() + scores = board.get_high_scores() + lines = ["High Scores:"] + for i, entry in enumerate(scores, 1): + scoreStr = f"{i}. {entry['name']}: {entry['score']}" + lines.append(scoreStr) + + pygame.event.clear() + display_text(lines) elif choice == "learn_sounds": choice = learn_sounds(self.sounds)