Warning sound for end of invincibility.

This commit is contained in:
Storm Dragon
2025-02-11 23:22:41 -05:00
parent c6adc193a1
commit af3ddb0efc
2 changed files with 24 additions and 5 deletions

View File

@@ -93,16 +93,32 @@ class Player:
if self.currentWeapon:
self.currentWeapon.attackDuration *= 0.5 # Restore attack speed
del self.webPenaltyEndTime
# Check if invincibility has expired
if self.isInvincible and currentTime - self.invincibilityStartTime >= self.invincibilityDuration:
self.isInvincible = False
speak("Invincibility wore off!")
# Check invincibility status
if self.isInvincible:
remaining_time = (self.invincibilityStartTime + self.invincibilityDuration - currentTime) / 1000 # Convert to seconds
# Handle countdown sounds
if not hasattr(self, '_last_countdown'):
self._last_countdown = 4 # Start counting from 4 to catch 3,2,1
current_second = int(remaining_time)
if current_second < self._last_countdown and current_second <= 3 and current_second > 0:
play_sound(self.sounds['end_of_invincibility_warning'])
self._last_countdown = current_second
# Check if invincibility has expired
if currentTime - self.invincibilityStartTime >= self.invincibilityDuration:
self.isInvincible = False
speak("Invincibility wore off!")
del self._last_countdown # Clean up countdown tracker
def start_invincibility(self):
"""Activate invincibility from Hand of Glory"""
self.isInvincible = True
self.invincibilityStartTime = pygame.time.get_ticks()
if hasattr(self, '_last_countdown'):
del self._last_countdown # Reset countdown if it exists
def extra_life(self):
"""Increment lives by 1"""