Added optional end of game cut scene. Make sure to specify utf-8 encoding for python files to work with pyinstaller.

This commit is contained in:
Storm Dragon
2025-02-17 20:09:46 -05:00
parent 1cd636b8f4
commit f5ea9dd278
15 changed files with 40 additions and 2 deletions

View File

@@ -1,4 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import json
import os
from libstormgames import *
@@ -56,7 +58,6 @@ class WickedQuest:
return True
except FileNotFoundError:
speak("Level not found")
return False
def handle_input(self):
@@ -272,7 +273,16 @@ class WickedQuest:
# Game complete - use gameStartTime for total
totalTime = pygame.time.get_ticks() - self.gameStartTime
if self.player.xPos >= self.currentLevel.rightBoundary:
messagebox("Congratulations! You've completed all available levels!")
# Check for end of game scene
gamePath = os.path.dirname(get_level_path(self.currentGame, 1))
for ext in ['.wav', '.ogg', '.mp3']:
endFile = os.path.join(gamePath, f'end{ext}')
if os.path.exists(endFile):
self.sounds['end_scene'] = pygame.mixer.Sound(endFile)
cut_scene(self.sounds, 'end_scene')
break
else:
messagebox("Congratulations! You've completed all available levels!")
self.display_game_over(totalTime)
return