New lighting!
This commit is contained in:
@@ -13,46 +13,67 @@ function CreateLight(x,y,range)
|
||||
}
|
||||
o.range = range
|
||||
o.flicker = 0
|
||||
o.dim = 0
|
||||
table.insert(Lights,o)
|
||||
return o
|
||||
end
|
||||
|
||||
function SetDarkness()
|
||||
love.graphics.setColor(0,0,0,1)
|
||||
love.graphics.rectangle("fill",0,0,game.width,game.height)
|
||||
end
|
||||
|
||||
function DoDarkness()
|
||||
love.graphics.setColor(0,0,0)
|
||||
love.graphics.setColor(0,0,0,0.3)
|
||||
love.graphics.rectangle("fill",0,0,game.width,game.height)
|
||||
end
|
||||
|
||||
function DoLights()
|
||||
LightTimer = LightTimer + 1
|
||||
|
||||
|
||||
if LightTimer >= 3 then
|
||||
LightTimer = LightTimer - 3
|
||||
for _, light in pairs(Lights) do
|
||||
light.flicker = math.random(-1,1)
|
||||
end
|
||||
light.flicker = math.random(-2,2)
|
||||
light.dim = (light.range+light.flicker)/5
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
love.graphics.setBlendMode("replace")
|
||||
-- first, border
|
||||
love.graphics.setColor(1,1,1)
|
||||
for _, light in pairs(Lights) do
|
||||
|
||||
love.graphics.circle(
|
||||
"fill",
|
||||
|
||||
--[[love.graphics.circle(
|
||||
"fill",
|
||||
light.pos.x - Camera.pos.x,
|
||||
light.pos.y - Camera.pos.y,
|
||||
light.range + light.flicker + 1
|
||||
)
|
||||
end
|
||||
love.graphics.setColor(0,0,0,0)
|
||||
-- then, light
|
||||
for _, light in pairs(Lights) do
|
||||
)]]
|
||||
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
|
||||
love.graphics.circle(
|
||||
"fill",
|
||||
"fill",
|
||||
light.pos.x - Camera.pos.x,
|
||||
light.pos.y - Camera.pos.y,
|
||||
light.range + light.flicker
|
||||
)
|
||||
)
|
||||
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
|
||||
)
|
||||
end
|
||||
love.graphics.setBlendMode("alpha")
|
||||
end
|
||||
@@ -62,4 +83,4 @@ end
|
||||
|
||||
function DrawDarkness()
|
||||
love.graphics.draw(Canvas.Darkness, 0, 0, 0, 0.5, 0.5)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user