summaryrefslogtreecommitdiffhomepage
path: root/not/Camera.lua
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2017-09-13 10:19:02 +0200
committerAki <nthirtyone@gmail.com>2017-09-13 10:19:02 +0200
commite8bd3dfd8031930fa3f0169300620e5a0400995d (patch)
tree931077a945dbd5d1ddb113972f8f5146fa5a4847 /not/Camera.lua
parent2a0cef0fba687e03fd322ac73c511bbb12b1e31c (diff)
downloadroflnauts-e8bd3dfd8031930fa3f0169300620e5a0400995d.zip
roflnauts-e8bd3dfd8031930fa3f0169300620e5a0400995d.tar.gz
roflnauts-e8bd3dfd8031930fa3f0169300620e5a0400995d.tar.bz2
Another attempt to fix real scaling bug
Diffstat (limited to 'not/Camera.lua')
-rw-r--r--not/Camera.lua24
1 files changed, 18 insertions, 6 deletions
diff --git a/not/Camera.lua b/not/Camera.lua
index 402a32b..b3b8128 100644
--- a/not/Camera.lua
+++ b/not/Camera.lua
@@ -26,11 +26,9 @@ function Camera:push ()
love.graphics.push()
end
--- TODO: self._scale usage is temporary, used for real scaling.
function Camera:scale (scale)
scale = scale or getScale()
love.graphics.scale(scale, scale)
- self._scale = scale
end
function Camera:translate (ratio)
@@ -46,6 +44,20 @@ function Camera:translate (ratio)
love.graphics.translate(ox - px - dx, oy - py - dy)
end
+-- TODO: TranslateReal is temporary.
+function Camera:translateReal (ratio)
+ local px, py = self:getPosition()
+ local dx, dy = self:getShake()
+ local ox, oy = self:getHalfViewSize(getRealScale())
+ if ratio then
+ dx = dx * ratio
+ dy = dy * ratio
+ px = px * ratio
+ py = py * ratio
+ end
+ love.graphics.translate(ox - px - dx, oy - py - dy)
+end
+
function Camera:pop ()
love.graphics.pop()
self._scale = nil
@@ -68,15 +80,15 @@ function Camera:getBoundaries ()
end
-- TODO: Review getViewSize of Camera.
-function Camera:getViewSize ()
- local scale = self._scale or getScale()
+function Camera:getViewSize (scale)
+ scale = scale or getScale()
local width = love.graphics.getWidth() / scale
local height = love.graphics.getHeight() / scale
return width, height
end
-function Camera:getHalfViewSize ()
- local width, height = self:getViewSize()
+function Camera:getHalfViewSize (scale)
+ local width, height = self:getViewSize(scale)
return width / 2, height / 2
end