Added points system with scoreboard.
This commit is contained in:
@@ -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)
|
||||
|
||||
|
Reference in New Issue
Block a user