wired switches and doors
This commit is contained in:
parent
ee7d36e72b
commit
bc4976b324
16 changed files with 2575 additions and 835 deletions
30
wired_door.lua
Normal file
30
wired_door.lua
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
require "door"
|
||||
|
||||
local Wire = require "wire"
|
||||
|
||||
WiredDoor = class("WiredDoor", Door)
|
||||
|
||||
function WiredDoor:initialize(x, y, color, circuitId)
|
||||
Door.initialize(self, x, y, color)
|
||||
self.circuitId = circuitId
|
||||
self.wired = true
|
||||
end
|
||||
|
||||
function WiredDoor:setPowered(powered)
|
||||
if powered then
|
||||
if self.locked then self:unlock() end
|
||||
elseif not self.locked then
|
||||
self:lock()
|
||||
end
|
||||
self:refreshSprites()
|
||||
end
|
||||
|
||||
function WiredDoor:draw(channel)
|
||||
Entity.draw(self, channel)
|
||||
if not self.sprites[channel] then return end
|
||||
local p = self:getDrawPos()
|
||||
local color = Wire.color(self.circuitId)
|
||||
love.graphics.setColor(color[1], color[2], color[3], 1)
|
||||
love.graphics.setLineWidth(math.max(1, drawScale))
|
||||
love.graphics.circle("line", p.x + 8 * drawScale, p.y + 8 * drawScale, 3 * drawScale)
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue