Got end of level working. Added floating coffins, shatter them and collect what comes out.
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
import pygame
|
||||
from libstormgames import *
|
||||
from src.weapon import Weapon
|
||||
|
||||
|
||||
class Player:
|
||||
def __init__(self, xPos, yPos):
|
||||
def __init__(self, xPos, yPos, sounds):
|
||||
self.sounds = sounds
|
||||
# Movement attributes
|
||||
self.xPos = xPos
|
||||
self.yPos = yPos
|
||||
@@ -98,15 +103,21 @@ class Player:
|
||||
return self._maxHealth
|
||||
|
||||
def set_health(self, value):
|
||||
"""Set health and handle death if needed"""
|
||||
"""Set health and handle death if needed."""
|
||||
if self.isInvincible:
|
||||
return # No damage while invincible
|
||||
|
||||
|
||||
old_health = self._health
|
||||
self._health = max(0, value) # Health can't go below 0
|
||||
if self._health == 0:
|
||||
|
||||
if self._health == 0 and old_health > 0:
|
||||
self._lives -= 1
|
||||
# Stop all current sounds before playing death sound
|
||||
pygame.mixer.stop()
|
||||
cut_scene(self.sounds, 'lose_a_life')
|
||||
if self._lives > 0:
|
||||
self._health = 10 # Reset health if we still have lives
|
||||
self._health = self._maxHealth # Reset health if we still have lives
|
||||
speak(f"{self._lives} lives remaining")
|
||||
|
||||
def set_max_health(self, value):
|
||||
"""Set max health"""
|
||||
|
Reference in New Issue
Block a user