optimization in whole tiles creation
This commit is contained in:
@@ -59,20 +59,25 @@ function DoLights()
|
||||
light.flicker = math.min(math.max(light.flicker, -light.flicker_value),light.flicker_value)
|
||||
end
|
||||
end
|
||||
|
||||
love.graphics.setBlendMode("replace")
|
||||
for _, light in pairs(Lights) do
|
||||
if light.range ~= 0 then
|
||||
love.graphics.setColor(light.color[1],light.color[2],light.color[3],1)
|
||||
local position = {
|
||||
x = (light.pos.x - Camera.pos.x) / game.scale,
|
||||
y = (light.pos.y - Camera.pos.y) / game.scale
|
||||
}
|
||||
local range = (1 + light.range + light.flicker) / game.scale
|
||||
love.graphics.circle(
|
||||
"fill",
|
||||
(light.pos.x - Camera.pos.x) / game.scale,
|
||||
(light.pos.y - Camera.pos.y) / game.scale,
|
||||
(light.range + light.flicker + 0) / game.scale
|
||||
position.x,
|
||||
position.y,
|
||||
range
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
myShader:send("game_scale", game.scale)
|
||||
love.graphics.setColor(0,0,0,0)
|
||||
for _, light in pairs(Lights) do
|
||||
if light.range ~= 0 then
|
||||
local position = {
|
||||
@@ -80,21 +85,30 @@ function DoLights()
|
||||
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",
|
||||
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)
|
||||
"fill",
|
||||
position.x,
|
||||
position.y,
|
||||
range
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
love.graphics.setBlendMode("alpha")
|
||||
love.graphics.setColor(0,0,0,1)
|
||||
Shaders.InsideLight: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
|
||||
Shaders.InsideLight:send("light_color", light.color)
|
||||
Shaders.InsideLight:send("light_pos", {position.x*game.scale, position.y*game.scale})
|
||||
Shaders.InsideLight:send("range", range)
|
||||
love.graphics.setShader(Shaders.InsideLight)
|
||||
love.graphics.circle(
|
||||
"fill",
|
||||
position.x,
|
||||
@@ -115,5 +129,5 @@ function DoBorder()
|
||||
end
|
||||
|
||||
function DrawDarkness()
|
||||
love.graphics.draw(Canvas.Darkness, 0, 0, 0, game.scale)
|
||||
love.graphics.draw(Canvas.Darkness, 0, 0, 0, 1/game.scale)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user