uh, a lot happened, i murdered physics code, redesigned tiles & levels, now i need to make another level editor. I'm sorry game. I'm sorry git.
This commit is contained in:
@@ -5,15 +5,19 @@ function CreateDarkness()
|
||||
return love.graphics.newCanvas(game.width, game.height)
|
||||
end
|
||||
|
||||
function CreateLight(x,y,range)
|
||||
function CreateLight(x,y,range,lum,flicker)
|
||||
local o = {}
|
||||
o.pos = {
|
||||
x = x,
|
||||
y = y
|
||||
}
|
||||
o.range = range
|
||||
o.lum = lum or 1
|
||||
o.flicker_value = flicker or 1
|
||||
o.flicker = 0
|
||||
o.dim = 0
|
||||
o.flicker_speed = flicker_speed or 10
|
||||
o.flicker_time = 0
|
||||
table.insert(Lights,o)
|
||||
return o
|
||||
end
|
||||
@@ -23,54 +27,46 @@ function SetDarkness()
|
||||
love.graphics.rectangle("fill",0,0,game.width,game.height)
|
||||
end
|
||||
|
||||
function DoDarkness()
|
||||
love.graphics.setColor(0,0,0,1)
|
||||
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)
|
||||
light.dim = (light.range+light.flicker)/2
|
||||
for _, light in pairs(Lights) do
|
||||
light.flicker_time = light.flicker_time + 1
|
||||
|
||||
if light.flicker_time >= light.flicker_speed then
|
||||
light.flicker_time = light.flicker_time - light.flicker_speed
|
||||
light.flicker = 0 + math.random(-1,1)
|
||||
light.flicker = math.min(math.max(light.flicker, -light.flicker_value),light.flicker_value)
|
||||
end
|
||||
end
|
||||
|
||||
love.graphics.setBlendMode("replace")
|
||||
--[[
|
||||
-- first, border
|
||||
love.graphics.setColor(1,1,1)
|
||||
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 + 1
|
||||
)]]
|
||||
love.graphics.circle(
|
||||
"fill",
|
||||
light.pos.x - Camera.pos.x,
|
||||
light.pos.y - Camera.pos.y,
|
||||
light.range + light.flicker + 1
|
||||
)
|
||||
end
|
||||
]]
|
||||
love.graphics.setBlendMode("replace")
|
||||
for _, enty in pairs(LoadedEntities) do
|
||||
end
|
||||
love.graphics.setColor(0,0,0,0.5)
|
||||
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
|
||||
)
|
||||
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
|
||||
)
|
||||
|
||||
local shades = 200
|
||||
for i=1, shades do
|
||||
for _, light in pairs(Lights) do
|
||||
local luminosity = shades*light.lum/100
|
||||
love.graphics.setColor(0,0,0,math.min(1,math.max(0,(shades-i-luminosity+1)/(shades-luminosity+1))))
|
||||
love.graphics.circle(
|
||||
"fill",
|
||||
light.pos.x - Camera.pos.x,
|
||||
light.pos.y - Camera.pos.y,
|
||||
(light.range + light.flicker)*(shades-i+1)/shades
|
||||
)
|
||||
end
|
||||
end
|
||||
love.graphics.setBlendMode("alpha")
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user