From f5ea9dd278a9ff670ca22ee75402da960a1f7d76 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Mon, 17 Feb 2025 20:09:46 -0500 Subject: [PATCH] Added optional end of game cut scene. Make sure to specify utf-8 encoding for python files to work with pyinstaller. --- src/catapult.py | 2 ++ src/coffin.py | 2 ++ src/enemy.py | 2 ++ src/game_selection.py | 2 ++ src/grave.py | 2 ++ src/item_types.py | 2 ++ src/level.py | 2 ++ src/object.py | 2 ++ src/player.py | 2 ++ src/powerup.py | 2 ++ src/projectile.py | 2 ++ src/skull_storm.py | 2 ++ src/stat_tracker.py | 2 ++ src/weapon.py | 2 ++ wicked_quest.py | 14 ++++++++++++-- 15 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/catapult.py b/src/catapult.py index 7709a81..86910ad 100644 --- a/src/catapult.py +++ b/src/catapult.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + from libstormgames import * from src.object import Object import random diff --git a/src/coffin.py b/src/coffin.py index 2a97ffb..d30dfa9 100644 --- a/src/coffin.py +++ b/src/coffin.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + import random from libstormgames import * from src.item_types import ItemProperties diff --git a/src/enemy.py b/src/enemy.py index b19c613..7607db0 100644 --- a/src/enemy.py +++ b/src/enemy.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + from libstormgames import * from src.object import Object from src.powerup import PowerUp diff --git a/src/game_selection.py b/src/game_selection.py index 779a932..e954489 100644 --- a/src/game_selection.py +++ b/src/game_selection.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + import os import time import pygame diff --git a/src/grave.py b/src/grave.py index 51d635c..544dad9 100644 --- a/src/grave.py +++ b/src/grave.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + from libstormgames import * from src.object import Object from src.powerup import PowerUp diff --git a/src/item_types.py b/src/item_types.py index 5bd14ad..e27931e 100644 --- a/src/item_types.py +++ b/src/item_types.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + import random from enum import Enum, auto diff --git a/src/level.py b/src/level.py index c2bff65..ba8e3dc 100644 --- a/src/level.py +++ b/src/level.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + import pygame import random from libstormgames import * diff --git a/src/object.py b/src/object.py index b1c42fd..abd5153 100644 --- a/src/object.py +++ b/src/object.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + from libstormgames import * class Object: diff --git a/src/player.py b/src/player.py index 7104d7c..23fe659 100644 --- a/src/player.py +++ b/src/player.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + import pygame from libstormgames import * from src.stat_tracker import StatTracker diff --git a/src/powerup.py b/src/powerup.py index e58abd2..f705608 100644 --- a/src/powerup.py +++ b/src/powerup.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + from libstormgames import * from src.object import Object from src.weapon import Weapon diff --git a/src/projectile.py b/src/projectile.py index 8b15882..9e74e89 100644 --- a/src/projectile.py +++ b/src/projectile.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + class Projectile: def __init__(self, projectile_type, start_x, direction): self.type = projectile_type diff --git a/src/skull_storm.py b/src/skull_storm.py index 9f71272..bfb3e8f 100644 --- a/src/skull_storm.py +++ b/src/skull_storm.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + from libstormgames import * from src.object import Object diff --git a/src/stat_tracker.py b/src/stat_tracker.py index f6fb7c7..92a8321 100644 --- a/src/stat_tracker.py +++ b/src/stat_tracker.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + class StatTracker: def __init__(self): # Base dictionary for tracking stats diff --git a/src/weapon.py b/src/weapon.py index 3c91cfd..4d4bdd7 100644 --- a/src/weapon.py +++ b/src/weapon.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + class Weapon: def __init__(self, name, damage, range, attackSound, hitSound, cooldown=500, attackDuration=200): self.name = name diff --git a/wicked_quest.py b/wicked_quest.py index b86fa70..b2f6a17 100755 --- a/wicked_quest.py +++ b/wicked_quest.py @@ -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