From 389eaed2850719e60046d54a5fcd934a0310664d Mon Sep 17 00:00:00 2001 From: lustlion Date: Tue, 18 Jan 2022 14:02:56 +0100 Subject: [PATCH] bit more of refactoring --- data/scripts/game.lua | 26 ++++++++++++++++---------- main.lua | 4 ++++ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/data/scripts/game.lua b/data/scripts/game.lua index 28d7a6b..22174ef 100644 --- a/data/scripts/game.lua +++ b/data/scripts/game.lua @@ -31,16 +31,6 @@ function drawEditor() end 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() gameworldLighting() @@ -60,11 +50,18 @@ function drawGame() end 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() love.graphics.scale(game.scale,game.scale) love.graphics.setColor(1,1,1,1) LevelDisplayBackground() + for _, enty in pairs(LoadedEntities) do enty:HandleAnimation() end @@ -74,6 +71,15 @@ function gameworldDraw() end 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 love.graphics.setCanvas(Canvas.Darkness) SetDarkness() diff --git a/main.lua b/main.lua index 8eedf9f..15b32fb 100644 --- a/main.lua +++ b/main.lua @@ -129,7 +129,11 @@ function love.draw() if game.width ~= love.graphics.getWidth() or game.height ~= love.graphics.getHeight() then game.width = love.graphics.getWidth() game.height = love.graphics.getHeight() + game_resize = true + else + game_resize = false end + if editor_mode then drawEditor() else