From 9aa820bf100845da2024bf3af9e802c90b3a6b51 Mon Sep 17 00:00:00 2001 From: Aki Date: Mon, 31 Jul 2017 22:20:41 +0200 Subject: Fixed scaling issues on display change --- not/Camera.lua | 14 ++++++-------- not/Menu.lua | 3 +-- not/World.lua | 4 ++-- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/not/Camera.lua b/not/Camera.lua index 63489f3..01d5962 100644 --- a/not/Camera.lua +++ b/not/Camera.lua @@ -5,8 +5,6 @@ Camera = { y = 0, dest_x = 0, dest_y = 0, - scale = getScale(), - scaler = getRealScale(), shake = 0, timer = 0, delay = 0, @@ -45,7 +43,7 @@ function Camera:getPosition () end function Camera:getPositionScaled () - return self.x*self.scale, self.y*self.scale + return self.x*getScale(), self.y*getScale() end -- Destination @@ -63,7 +61,7 @@ end function Camera:translatePosition (x, y) local x = x or 0 local y = y or 0 - return (x-self.x)*self.scale, (y-self.y)*self.scale + return (x-self.x)*getScale().scale, (y-self.y)*getScale() end function Camera:translatePoints(...) @@ -72,9 +70,9 @@ function Camera:translatePoints(...) local x,y = self:getOffsets() for k,v in pairs(a) do if k%2 == 1 then - table.insert(r, (v + x) * self.scale) + table.insert(r, (v + x) * getScale()) else - table.insert(r, (v + y) * self.scale) + table.insert(r, (v + y) * getScale()) end end return r @@ -120,8 +118,8 @@ function Camera:follow () sum_y = naut_y + sum_y end end - local x = sum_x / i - love.graphics.getWidth()/self.scale/2 - local y = sum_y / i - love.graphics.getHeight()/self.scale/2 + 4*self.scale -- hotfix + local x = sum_x / i - love.graphics.getWidth()/getScale()/2 + local y = sum_y / i - love.graphics.getHeight()/getScale()/2 + 4*getScale() -- hotfix return x,y end diff --git a/not/Menu.lua b/not/Menu.lua index b835777..b7fc7ed 100644 --- a/not/Menu.lua +++ b/not/Menu.lua @@ -3,7 +3,6 @@ -- I do know that model I used here and in `World` loading configuration files is not flawless but I did not want to rewrite `World`s one but wanted to keep things similar at least in project scope. Menu = require "not.Scene":extends() -Menu.scale = getScale() Menu.elements = --[[{not.Element}]]nil Menu.active = 1 Menu.music = --[[not.Music]]nil @@ -79,7 +78,7 @@ function Menu:update (dt) end end function Menu:draw () - local scale = self.scale + local scale = getScale() local scaler = getRealScale() love.graphics.setFont(Font) for _,element in pairs(self.elements) do diff --git a/not/World.lua b/not/World.lua index 7317617..c73a3da 100644 --- a/not/World.lua +++ b/not/World.lua @@ -251,8 +251,8 @@ end function World:draw () -- Camera stuff local offset_x, offset_y = self.camera:getOffsets() - local scale = self.camera.scale - local scaler = self.camera.scaler + local scale = getScale() + local scaler = getRealScale() -- Background love.graphics.draw(self.background, 0, 0, 0, scaler, scaler) -- cgit v1.1