bit more of refactoring

This commit is contained in:
lustlion 2022-01-18 14:02:56 +01:00
parent 0b18fcd369
commit 389eaed285
2 changed files with 20 additions and 10 deletions

View File

@ -31,16 +31,6 @@ function drawEditor()
end end
function drawGame() function drawGame()
-- saveproof to game resize
if game.width ~= love.graphics.getWidth() or game.height ~= love.graphics.getHeight() then
Camera.height = game.height
Camera.width = game.width
Canvas.Darkness:release()
Canvas.Darkness = CreateDarkness()
love.graphics.setCanvas(Canvas.Darkness)
SetDarkness()
love.graphics.setCanvas()
end
gameworldDraw() gameworldDraw()
gameworldLighting() gameworldLighting()
@ -60,11 +50,18 @@ function drawGame()
end end
function gameworldDraw() function gameworldDraw()
-- resize proof
if game_resize then
Camera.height = game.height
Camera.width = game.width
end
local pcr, pcg, pcb, pca = love.graphics.getColor() local pcr, pcg, pcb, pca = love.graphics.getColor()
love.graphics.scale(game.scale,game.scale) love.graphics.scale(game.scale,game.scale)
love.graphics.setColor(1,1,1,1) love.graphics.setColor(1,1,1,1)
LevelDisplayBackground() LevelDisplayBackground()
for _, enty in pairs(LoadedEntities) do for _, enty in pairs(LoadedEntities) do
enty:HandleAnimation() enty:HandleAnimation()
end end
@ -74,6 +71,15 @@ function gameworldDraw()
end end
function gameworldLighting() function gameworldLighting()
if game_resize then
Canvas.Darkness:release()
Canvas.Darkness = CreateDarkness()
love.graphics.setCanvas(Canvas.Darkness)
SetDarkness()
love.graphics.setCanvas()
end
-- work on lighting canvas -- work on lighting canvas
love.graphics.setCanvas(Canvas.Darkness) love.graphics.setCanvas(Canvas.Darkness)
SetDarkness() SetDarkness()

View File

@ -129,7 +129,11 @@ function love.draw()
if game.width ~= love.graphics.getWidth() or game.height ~= love.graphics.getHeight() then if game.width ~= love.graphics.getWidth() or game.height ~= love.graphics.getHeight() then
game.width = love.graphics.getWidth() game.width = love.graphics.getWidth()
game.height = love.graphics.getHeight() game.height = love.graphics.getHeight()
game_resize = true
else
game_resize = false
end end
if editor_mode then if editor_mode then
drawEditor() drawEditor()
else else