Warning sound for end of invincibility.
This commit is contained in:
BIN
sounds/end_of_invincibility_warning.ogg
(Stored with Git LFS)
Normal file
BIN
sounds/end_of_invincibility_warning.ogg
(Stored with Git LFS)
Normal file
Binary file not shown.
@@ -94,15 +94,31 @@ class Player:
|
|||||||
self.currentWeapon.attackDuration *= 0.5 # Restore attack speed
|
self.currentWeapon.attackDuration *= 0.5 # Restore attack speed
|
||||||
del self.webPenaltyEndTime
|
del self.webPenaltyEndTime
|
||||||
|
|
||||||
|
# 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
|
# Check if invincibility has expired
|
||||||
if self.isInvincible and currentTime - self.invincibilityStartTime >= self.invincibilityDuration:
|
if currentTime - self.invincibilityStartTime >= self.invincibilityDuration:
|
||||||
self.isInvincible = False
|
self.isInvincible = False
|
||||||
speak("Invincibility wore off!")
|
speak("Invincibility wore off!")
|
||||||
|
del self._last_countdown # Clean up countdown tracker
|
||||||
|
|
||||||
def start_invincibility(self):
|
def start_invincibility(self):
|
||||||
"""Activate invincibility from Hand of Glory"""
|
"""Activate invincibility from Hand of Glory"""
|
||||||
self.isInvincible = True
|
self.isInvincible = True
|
||||||
self.invincibilityStartTime = pygame.time.get_ticks()
|
self.invincibilityStartTime = pygame.time.get_ticks()
|
||||||
|
if hasattr(self, '_last_countdown'):
|
||||||
|
del self._last_countdown # Reset countdown if it exists
|
||||||
|
|
||||||
def extra_life(self):
|
def extra_life(self):
|
||||||
"""Increment lives by 1"""
|
"""Increment lives by 1"""
|
||||||
|
Reference in New Issue
Block a user