diff --git a/imperium-porcorum.love/scenes/levels/entities/player.lua b/imperium-porcorum.love/scenes/levels/entities/player.lua index 9e2a9e3..db7da5e 100644 --- a/imperium-porcorum.love/scenes/levels/entities/player.lua +++ b/imperium-porcorum.love/scenes/levels/entities/player.lua @@ -66,6 +66,15 @@ end -- UPDATE and COLLISION functions -- Physics and function called every game update +function Player:update(dt) + if (self.isAlive) then + Player.super.update(self, dt) + else + -- Only update timers if the player is dead + self:updateTimers(dt) + end +end + function Player:updateStart(dt) self.keys = self.scene.sources[1].keys @@ -200,6 +209,12 @@ end -- DRAW functions +function Player:draw() + if (self.isAlive) then + Player.super.draw(self) + end +end + function Player:setAnimation() local animation = "idle" self:setSpriteScallingX(self.direction) @@ -245,7 +260,7 @@ function Player:drawHUD() local weapon = 0 love.graphics.draw(self.itembox, 16, 16) - if (true) then + if (self.isAlive) then hp = self.hp / self.stats.maxHP mp = self.mp / self.stats.maxMP weapon = self.weapon @@ -267,11 +282,11 @@ function Player:drawHUD() utils.graphics.resetColor() end -function Player:getScore(score) +function Player:addScore(score) self.score = self.score + score end -function Player:getGold(gold) +function Player:addGold(gold) self.gold = self.gold + gold end @@ -281,6 +296,8 @@ end function Player:resetLife() self.hp = self.stats.maxHP self.mp = self.stats.maxMP + + self.isAlive = true end function Player:takeHit(damage)