2021-10-25 23:19:22 +00:00
|
|
|
Lights = {}
|
|
|
|
LightTimer = 0
|
|
|
|
|
|
|
|
function CreateDarkness()
|
2021-10-25 23:23:57 +00:00
|
|
|
return love.graphics.newCanvas(game.width, game.height)
|
2021-10-25 23:19:22 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function CreateLight(x,y,range)
|
|
|
|
local o = {}
|
|
|
|
o.pos = {
|
|
|
|
x = x,
|
|
|
|
y = y
|
|
|
|
}
|
|
|
|
o.range = range
|
|
|
|
o.flicker = 0
|
2021-10-27 09:06:08 +00:00
|
|
|
o.dim = 0
|
2021-10-25 23:19:22 +00:00
|
|
|
table.insert(Lights,o)
|
|
|
|
return o
|
|
|
|
end
|
|
|
|
|
2021-10-27 09:06:08 +00:00
|
|
|
function SetDarkness()
|
|
|
|
love.graphics.setColor(0,0,0,1)
|
|
|
|
love.graphics.rectangle("fill",0,0,game.width,game.height)
|
|
|
|
end
|
|
|
|
|
2021-10-25 23:19:22 +00:00
|
|
|
function DoDarkness()
|
2021-10-27 09:06:08 +00:00
|
|
|
love.graphics.setColor(0,0,0,0.3)
|
2021-10-25 23:19:22 +00:00
|
|
|
love.graphics.rectangle("fill",0,0,game.width,game.height)
|
|
|
|
end
|
|
|
|
|
|
|
|
function DoLights()
|
|
|
|
LightTimer = LightTimer + 1
|
2021-10-27 09:06:08 +00:00
|
|
|
|
2021-10-25 23:19:22 +00:00
|
|
|
if LightTimer >= 3 then
|
|
|
|
LightTimer = LightTimer - 3
|
|
|
|
for _, light in pairs(Lights) do
|
2021-10-27 09:06:08 +00:00
|
|
|
light.flicker = math.random(-2,2)
|
|
|
|
light.dim = (light.range+light.flicker)/5
|
|
|
|
end
|
2021-10-25 23:19:22 +00:00
|
|
|
end
|
2021-10-27 09:06:08 +00:00
|
|
|
|
2021-10-25 23:19:22 +00:00
|
|
|
love.graphics.setBlendMode("replace")
|
|
|
|
-- first, border
|
|
|
|
love.graphics.setColor(1,1,1)
|
|
|
|
for _, light in pairs(Lights) do
|
2021-10-27 09:06:08 +00:00
|
|
|
|
|
|
|
--[[love.graphics.circle(
|
|
|
|
"fill",
|
2021-10-25 23:19:22 +00:00
|
|
|
light.pos.x - Camera.pos.x,
|
|
|
|
light.pos.y - Camera.pos.y,
|
|
|
|
light.range + light.flicker + 1
|
2021-10-27 09:06:08 +00:00
|
|
|
)]]
|
|
|
|
end
|
|
|
|
for _, enty in pairs(LoadedEntities) do
|
|
|
|
if enty.illuminated == true then
|
|
|
|
enty:Draw()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
love.graphics.setColor(0,0,0,0.5)
|
|
|
|
for _, light in pairs(Lights) do
|
2021-10-25 23:19:22 +00:00
|
|
|
love.graphics.circle(
|
2021-10-27 09:06:08 +00:00
|
|
|
"fill",
|
2021-10-25 23:19:22 +00:00
|
|
|
light.pos.x - Camera.pos.x,
|
|
|
|
light.pos.y - Camera.pos.y,
|
|
|
|
light.range + light.flicker
|
2021-10-27 09:06:08 +00:00
|
|
|
)
|
|
|
|
end
|
|
|
|
-- then, light
|
|
|
|
love.graphics.setColor(0,0,0,0)
|
|
|
|
for _, light in pairs(Lights) do
|
|
|
|
love.graphics.circle(
|
|
|
|
"fill",
|
|
|
|
light.pos.x - Camera.pos.x,
|
|
|
|
light.pos.y - Camera.pos.y,
|
|
|
|
light.range + light.flicker - light.dim
|
|
|
|
)
|
2021-10-25 23:19:22 +00:00
|
|
|
end
|
|
|
|
love.graphics.setBlendMode("alpha")
|
|
|
|
end
|
|
|
|
|
|
|
|
function DoBorder()
|
|
|
|
end
|
|
|
|
|
|
|
|
function DrawDarkness()
|
2021-10-25 23:23:57 +00:00
|
|
|
love.graphics.draw(Canvas.Darkness, 0, 0, 0, 0.5, 0.5)
|
2021-10-27 09:06:08 +00:00
|
|
|
end
|