Skip to content

Commit

Permalink
Player changes color on death
Browse files Browse the repository at this point in the history
  • Loading branch information
nullenvk committed May 14, 2022
1 parent f76b89e commit 1faed9d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ local SIDE_ACCEL = 5000
local GRAV_ACCEL = 3000
local FLIP_DELAY = 0.15

local COLOR_ALIVE = {0.2, 0.2, 1, 1}
local COLOR_DEATH = {1, 0.2, 0.2, 1}

local TEXTURE_PATH_PLAYER = "res/player.png"

Player = Sprite:new()
Expand Down Expand Up @@ -67,7 +70,10 @@ function Player:update(dt)
self.deathTimer = self.deathTimer + dt

if not self.isDead then
self.spriteColor = COLOR_ALIVE
self:updateNormal(dt)
else
self.spriteColor = COLOR_DEATH
end

self.spritePosX = self.pos.x
Expand Down
Binary file modified res/menubg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified res/player.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion sprite.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ function Sprite:new(o)
o.spriteFlipX = false
o.spriteFlipY = false
o.spriteSub = 1
o.spriteColor = {1, 1, 1}

return o
end
Expand Down Expand Up @@ -51,7 +52,7 @@ function Sprite:draw()
local offsetY = self.spriteFlipY and self.spriteSizeH or 0
local curQuad = self.spriteQuads[self.spriteSub]

love.graphics.setColor(1,1,1)
love.graphics.setColor(self.spriteColor)
love.graphics.draw(self.spriteTexture, curQuad,
self.spritePosX + offsetX,
self.spritePosY + offsetY,
Expand Down

0 comments on commit 1faed9d

Please sign in to comment.