Lights = {} LightTimer = 0 function CreateDarkness() return love.graphics.newCanvas(game.width, game.height) end function CreateLight(x,y,range) local o = {} o.pos = { x = x, y = y } 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,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(-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", light.pos.x - Camera.pos.x, light.pos.y - Camera.pos.y, light.range + light.flicker + 1 )]] 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", 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 function DoBorder() end function DrawDarkness() love.graphics.draw(Canvas.Darkness, 0, 0, 0, 0.5, 0.5) end