Added random delay to the firing

This commit is contained in:
2025-06-22 18:26:41 +01:00
parent decb36295d
commit c0727b2f02

11
game.py
View File

@ -19,8 +19,6 @@ class Game(gameUtils.Game):
# Don't remove this. It does important things. :3
super().__init__(*args, **kwargs)
# TODO: Add a random delay between the spin and fire
# TODO: Utiles the following new sounds:
# gun-load: Should be played at the beginning of the game,
# and should have an animation accompanying it.
@ -80,15 +78,18 @@ class Game(gameUtils.Game):
self.playSound(self.gunShot)
elif event.key == pygame.K_3:
self.playSound(self.gunSpin)
elif event.key == pygame.K_SPACE:
elif event.key == pygame.K_SPACE and not self.awaitingTimeout("FireDelay"):
self.gun.playAnim('spin')
elif event.type == gameUtils.AnimStart:
if event.objectID == self.gun.objectID and event.animationID == 'spin':
self.playSound(self.gunSpin)
elif event.type == gameUtils.AnimFinish:
if event.objectID == self.gun.objectID and event.animationID == 'spin':
self.shockScale += self.fire() #check if the user gets shot
self.shockScale = min(self.shockScale, 1) #keeps shockScale in bounds
self.timeout("FireDelay",randint(0,2000)/1000)
elif event.type == gameUtils.Timeout:
self.shockScale += self.fire() #check if the user gets shot
self.shockScale = min(self.shockScale, 1) #keeps shockScale in bounds
def update(self):
"""