Fixed a few bugs in console commands.
This commit is contained in:
+22
-4
@@ -36,6 +36,9 @@ class WickedQuest:
|
|||||||
|
|
||||||
# Console system - no longer needed since we use get_input directly
|
# Console system - no longer needed since we use get_input directly
|
||||||
|
|
||||||
|
# Level tracking for proper progression
|
||||||
|
self.currentLevelNum = 1
|
||||||
|
|
||||||
def initialize_pack_sounds(self):
|
def initialize_pack_sounds(self):
|
||||||
"""Initialize pack-specific sound system after game selection."""
|
"""Initialize pack-specific sound system after game selection."""
|
||||||
if self.currentGame:
|
if self.currentGame:
|
||||||
@@ -212,8 +215,20 @@ class WickedQuest:
|
|||||||
# Extract level number from choice
|
# Extract level number from choice
|
||||||
levelNum = int(choice.split()[-1])
|
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
|
# Load the selected level
|
||||||
if self.load_level(levelNum):
|
if self.load_level(levelNum):
|
||||||
|
# Update the current level counter for proper progression
|
||||||
|
self.currentLevelNum = levelNum
|
||||||
speak(f"Warped to level {levelNum}")
|
speak(f"Warped to level {levelNum}")
|
||||||
else:
|
else:
|
||||||
speak(f"Failed to load level {levelNum}")
|
speak(f"Failed to load level {levelNum}")
|
||||||
@@ -222,6 +237,9 @@ class WickedQuest:
|
|||||||
"""Open the console for input and process the command."""
|
"""Open the console for input and process the command."""
|
||||||
from libstormgames import get_input
|
from libstormgames import get_input
|
||||||
|
|
||||||
|
# Clear events before opening console for PyInstaller compatibility
|
||||||
|
pygame.event.clear()
|
||||||
|
|
||||||
# Get console input using libstormgames text input
|
# Get console input using libstormgames text input
|
||||||
command = get_input("Enter console command:")
|
command = get_input("Enter console command:")
|
||||||
|
|
||||||
@@ -552,7 +570,7 @@ class WickedQuest:
|
|||||||
"""Main game loop handling updates and state changes."""
|
"""Main game loop handling updates and state changes."""
|
||||||
clock = pygame.time.Clock()
|
clock = pygame.time.Clock()
|
||||||
levelStartTime = pygame.time.get_ticks()
|
levelStartTime = pygame.time.get_ticks()
|
||||||
currentLevelNum = startingLevelNum
|
self.currentLevelNum = startingLevelNum
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
currentTime = pygame.time.get_ticks()
|
currentTime = pygame.time.get_ticks()
|
||||||
@@ -631,7 +649,7 @@ class WickedQuest:
|
|||||||
else:
|
else:
|
||||||
pygame.mixer.stop()
|
pygame.mixer.stop()
|
||||||
self.currentLevel.player._health = self.currentLevel.player._maxHealth
|
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
|
levelStartTime = pygame.time.get_ticks() # Reset level timer
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -641,8 +659,8 @@ class WickedQuest:
|
|||||||
levelTime = pygame.time.get_ticks() - levelStartTime
|
levelTime = pygame.time.get_ticks() - levelStartTime
|
||||||
self.display_level_stats(levelTime)
|
self.display_level_stats(levelTime)
|
||||||
|
|
||||||
currentLevelNum += 1
|
self.currentLevelNum += 1
|
||||||
if self.load_level(currentLevelNum):
|
if self.load_level(self.currentLevelNum):
|
||||||
# Auto save at the beginning of new level if conditions are met
|
# Auto save at the beginning of new level if conditions are met
|
||||||
self.auto_save()
|
self.auto_save()
|
||||||
levelStartTime = pygame.time.get_ticks() # Reset level timer for new level
|
levelStartTime = pygame.time.get_ticks() # Reset level timer for new level
|
||||||
|
|||||||
Reference in New Issue
Block a user