Shader for lighting, fairy line of view, tileset change, broke lights, sorry
This commit is contained in:
@@ -38,12 +38,18 @@ function KillLight(light)
|
||||
end
|
||||
|
||||
function SetDarkness()
|
||||
love.graphics.setCanvas(Canvas.Darkness)
|
||||
|
||||
love.graphics.setColor(0,0,0,1)
|
||||
love.graphics.rectangle("fill",0,0,game.width ,game.height)
|
||||
|
||||
love.graphics.setCanvas()
|
||||
end
|
||||
|
||||
function DoLights()
|
||||
|
||||
love.graphics.setCanvas(Canvas.Darkness)
|
||||
|
||||
for _, light in pairs(Lights) do
|
||||
light.flicker_time = light.flicker_time + 1
|
||||
|
||||
@@ -61,27 +67,53 @@ function DoLights()
|
||||
"fill",
|
||||
(light.pos.x - Camera.pos.x) / game.scale,
|
||||
(light.pos.y - Camera.pos.y) / game.scale,
|
||||
(light.range + light.flicker + 1) / game.scale
|
||||
(light.range + light.flicker + 0) / game.scale
|
||||
)
|
||||
end
|
||||
end
|
||||
love.graphics.setColor(0,0,0,0)
|
||||
|
||||
myShader:send("game_scale", game.scale)
|
||||
for _, light in pairs(Lights) do
|
||||
if light.range ~= 0 then
|
||||
local position = {
|
||||
x = (light.pos.x - Camera.pos.x) / game.scale,
|
||||
y = (light.pos.y - Camera.pos.y) / game.scale
|
||||
}
|
||||
local range = (light.range + light.flicker) / game.scale
|
||||
love.graphics.setBlendMode("replace")
|
||||
love.graphics.setColor(0,0,0,0)
|
||||
love.graphics.setShader()
|
||||
love.graphics.circle(
|
||||
"fill",
|
||||
(light.pos.x - Camera.pos.x) / game.scale,
|
||||
(light.pos.y - Camera.pos.y) / game.scale,
|
||||
(light.range + light.flicker) / game.scale
|
||||
position.x,
|
||||
position.y,
|
||||
range
|
||||
)
|
||||
love.graphics.setBlendMode("alpha")
|
||||
love.graphics.setColor(1,1,1)
|
||||
myShader:send("light_color", light.color)
|
||||
myShader:send("light_pos", {position.x*game.scale, position.y*game.scale})
|
||||
myShader:send("range", range)
|
||||
love.graphics.setShader(myShader)
|
||||
love.graphics.circle(
|
||||
"fill",
|
||||
position.x,
|
||||
position.y,
|
||||
range
|
||||
)
|
||||
love.graphics.setShader()
|
||||
end
|
||||
end
|
||||
love.graphics.setBlendMode("alpha")
|
||||
|
||||
love.graphics.setCanvas()
|
||||
|
||||
end
|
||||
|
||||
function DoBorder()
|
||||
love.graphics.setCanvas(Canvas.Darkness)
|
||||
love.graphics.setCanvas()
|
||||
end
|
||||
|
||||
function DrawDarkness()
|
||||
love.graphics.draw(Canvas.Darkness, 0, 0, 0, 2/game.scale)
|
||||
love.graphics.draw(Canvas.Darkness, 0, 0, 0, game.scale)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user