diff --git a/wicked_quest.py b/wicked_quest.py index 5094f8f..3bc223c 100755 --- a/wicked_quest.py +++ b/wicked_quest.py @@ -36,6 +36,9 @@ class WickedQuest: # Console system - no longer needed since we use get_input directly + # Level tracking for proper progression + self.currentLevelNum = 1 + def initialize_pack_sounds(self): """Initialize pack-specific sound system after game selection.""" if self.currentGame: @@ -212,8 +215,20 @@ class WickedQuest: # Extract level number from choice levelNum = int(choice.split()[-1]) + # Stop all sounds and music before warping + pygame.mixer.stop() + try: + pygame.mixer.music.stop() + except: + pass + + # Clear events for clean transition + pygame.event.clear() + # Load the selected level if self.load_level(levelNum): + # Update the current level counter for proper progression + self.currentLevelNum = levelNum speak(f"Warped to level {levelNum}") else: speak(f"Failed to load level {levelNum}") @@ -222,6 +237,9 @@ class WickedQuest: """Open the console for input and process the command.""" from libstormgames import get_input + # Clear events before opening console for PyInstaller compatibility + pygame.event.clear() + # Get console input using libstormgames text input command = get_input("Enter console command:") @@ -552,7 +570,7 @@ class WickedQuest: """Main game loop handling updates and state changes.""" clock = pygame.time.Clock() levelStartTime = pygame.time.get_ticks() - currentLevelNum = startingLevelNum + self.currentLevelNum = startingLevelNum while True: currentTime = pygame.time.get_ticks() @@ -631,7 +649,7 @@ class WickedQuest: else: pygame.mixer.stop() self.currentLevel.player._health = self.currentLevel.player._maxHealth - self.load_level(currentLevelNum) + self.load_level(self.currentLevelNum) levelStartTime = pygame.time.get_ticks() # Reset level timer continue @@ -641,8 +659,8 @@ class WickedQuest: levelTime = pygame.time.get_ticks() - levelStartTime self.display_level_stats(levelTime) - currentLevelNum += 1 - if self.load_level(currentLevelNum): + self.currentLevelNum += 1 + if self.load_level(self.currentLevelNum): # Auto save at the beginning of new level if conditions are met self.auto_save() levelStartTime = pygame.time.get_ticks() # Reset level timer for new level