If wielding witch broom instantly land when jumping by pressing down.
This commit is contained in:
@@ -28,6 +28,7 @@ class WickedQuest:
|
|||||||
self.runLock = False # Toggle behavior of the run keys
|
self.runLock = False # Toggle behavior of the run keys
|
||||||
self.saveManager = SaveManager()
|
self.saveManager = SaveManager()
|
||||||
self.survivalGenerator = None
|
self.survivalGenerator = None
|
||||||
|
self.lastBroomLandingTime = 0 # Timestamp to prevent ducking after broom landing
|
||||||
self.survivalWave = 1
|
self.survivalWave = 1
|
||||||
self.survivalScore = 0
|
self.survivalScore = 0
|
||||||
|
|
||||||
@@ -161,10 +162,17 @@ class WickedQuest:
|
|||||||
currentTime = pygame.time.get_ticks()
|
currentTime = pygame.time.get_ticks()
|
||||||
|
|
||||||
# Update running and ducking states
|
# Update running and ducking states
|
||||||
if (keys[pygame.K_s] or keys[pygame.K_DOWN]) and not player.isDucking:
|
# Don't handle ducking if jumping (down key is used for instant landing with broom)
|
||||||
player.duck()
|
# Also prevent ducking for 250ms after broom landing to avoid conflict
|
||||||
elif (not keys[pygame.K_s] and not keys[pygame.K_DOWN]) and player.isDucking:
|
broomLandingGracePeriod = 250 # milliseconds
|
||||||
player.stand()
|
recentBroomLanding = (hasattr(self, 'lastBroomLandingTime') and
|
||||||
|
currentTime - self.lastBroomLandingTime < broomLandingGracePeriod)
|
||||||
|
|
||||||
|
if not player.isJumping and not recentBroomLanding:
|
||||||
|
if (keys[pygame.K_s] or keys[pygame.K_DOWN]) and not player.isDucking:
|
||||||
|
player.duck()
|
||||||
|
elif (not keys[pygame.K_s] and not keys[pygame.K_DOWN]) and player.isDucking:
|
||||||
|
player.stand()
|
||||||
|
|
||||||
if self.runLock:
|
if self.runLock:
|
||||||
player.isRunning = not (keys[pygame.K_SPACE] or keys[pygame.K_LSHIFT] or keys[pygame.K_RSHIFT])
|
player.isRunning = not (keys[pygame.K_SPACE] or keys[pygame.K_LSHIFT] or keys[pygame.K_RSHIFT])
|
||||||
@@ -241,7 +249,18 @@ class WickedQuest:
|
|||||||
player.jumpStartTime = currentTime
|
player.jumpStartTime = currentTime
|
||||||
play_sound(self.sounds['jump'])
|
play_sound(self.sounds['jump'])
|
||||||
|
|
||||||
# Check if jump should end
|
# Handle instant landing with broom (press down while jumping)
|
||||||
|
if (player.isJumping and (keys[pygame.K_s] or keys[pygame.K_DOWN]) and
|
||||||
|
player.currentWeapon and player.currentWeapon.name == "witch_broom"):
|
||||||
|
player.isJumping = False
|
||||||
|
play_sound(self.sounds[player.footstepSound]) # Landing sound
|
||||||
|
# Reset step distance tracking after landing
|
||||||
|
player.distanceSinceLastStep = 0
|
||||||
|
player.lastStepTime = currentTime
|
||||||
|
# Set timestamp to prevent immediate ducking after broom landing
|
||||||
|
self.lastBroomLandingTime = currentTime
|
||||||
|
|
||||||
|
# Check if jump should end naturally
|
||||||
if player.isJumping and currentTime - player.jumpStartTime >= player.get_current_jump_duration():
|
if player.isJumping and currentTime - player.jumpStartTime >= player.get_current_jump_duration():
|
||||||
player.isJumping = False
|
player.isJumping = False
|
||||||
play_sound(self.sounds[player.footstepSound]) # Landing sound
|
play_sound(self.sounds[player.footstepSound]) # Landing sound
|
||||||
|
Reference in New Issue
Block a user