fix renderer
This commit is contained in:
parent
3ceb07f4d1
commit
886679816b
3 changed files with 42 additions and 56 deletions
35
door.lua
35
door.lua
|
|
@ -8,7 +8,11 @@ function Door:initialize(x, y)
|
|||
y = y,
|
||||
color = "white",
|
||||
collision = "unmoveable",
|
||||
sprite = sprites.door["green"] --doesn't matter for now which we put here b/c, we override the draw function neway
|
||||
sprites = {
|
||||
red = sprites.door.red,
|
||||
green = sprites.door.green,
|
||||
blue = sprites.door.blue,
|
||||
},
|
||||
})
|
||||
self.locked = true
|
||||
|
||||
|
|
@ -16,26 +20,19 @@ function Door:initialize(x, y)
|
|||
for _, color in pairs({"red", "green", "blue"}) do
|
||||
self.colors[color] = true --these are currently loc_ed
|
||||
end
|
||||
self:refreshSprites()
|
||||
end
|
||||
|
||||
function Door:draw()
|
||||
if self.locked then
|
||||
for color, active in pairs(self.colors) do
|
||||
if active then
|
||||
love.graphics.setColor(gColor[color]:set())
|
||||
local p = self:getDrawPos()
|
||||
love.graphics.draw(sprites.door[color], p.x + self.drawOffset.x, p.y + self.drawOffset.y, 0, drawScale, drawScale)
|
||||
end
|
||||
-- keep the per-channel sprite map in sync with lock state so the shared
|
||||
-- Entity:draw(channel) renders the door with no door-specific draw code
|
||||
function Door:refreshSprites()
|
||||
self.sprites = {}
|
||||
for _, c in ipairs({"red", "green", "blue"}) do
|
||||
if self.locked then
|
||||
if self.colors[c] then self.sprites[c] = sprites.door[c] end
|
||||
else
|
||||
self.sprites[c] = sprites.door.unlocked
|
||||
end
|
||||
love.graphics.setColor(gColor.white:set())
|
||||
local p = self:getDrawPos()
|
||||
love.graphics.draw(sprites.door["white"], p.x + self.drawOffset.x, p.y + self.drawOffset.y, 0, drawScale, drawScale)
|
||||
else
|
||||
for color, active in pairs(self.colors) do
|
||||
love.graphics.setColor(gColor[color]:set())
|
||||
local p = self:getDrawPos()
|
||||
love.graphics.draw(sprites.door["unlocked"], p.x + self.drawOffset.x, p.y + self.drawOffset.y, 0, drawScale, drawScale)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -56,6 +53,8 @@ function Door:setColors(colors)
|
|||
else
|
||||
if not self.locked then self:lock() end
|
||||
end
|
||||
|
||||
self:refreshSprites()
|
||||
end
|
||||
|
||||
function Door:unlock()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue