summaryrefslogtreecommitdiffhomepage
path: root/not/Camera.lua
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2017-09-11 19:22:18 +0200
committerAki <nthirtyone@gmail.com>2017-09-11 19:22:18 +0200
commit81ec1a6509b0f349c145dd1b4d40029d141cbd6e (patch)
tree9e8f9211974ca5559d144e43307963972f5c744e /not/Camera.lua
parent9ddacd0f6481661cdaeab8abf2000b45a296faee (diff)
downloadroflnauts-81ec1a6509b0f349c145dd1b4d40029d141cbd6e.zip
roflnauts-81ec1a6509b0f349c145dd1b4d40029d141cbd6e.tar.gz
roflnauts-81ec1a6509b0f349c145dd1b4d40029d141cbd6e.tar.bz2
Debug drawing changed to use new Camera properly
Diffstat (limited to 'not/Camera.lua')
-rw-r--r--not/Camera.lua32
1 files changed, 18 insertions, 14 deletions
diff --git a/not/Camera.lua b/not/Camera.lua
index 76f36ed..025e9e5 100644
--- a/not/Camera.lua
+++ b/not/Camera.lua
@@ -21,6 +21,7 @@ function Camera:initShake ()
}
end
+-- TODO: Even more magic numbers present in Camera. Translate method.
function Camera:translate ()
local x, y = self:getPositionScaled()
local dx, dy = self:getShakeScaled()
@@ -47,22 +48,25 @@ function Camera:getPositionScaled ()
return self.x * scale, self.y * scale
end
-function Camera:translatePosition (x, y)
- local x = x or 0
- local y = y or 0
- return (x-self.x)*getScale(), (y-self.y)*getScale()
+-- TODO: Magic numbers present in camera's boundaries.
+function Camera:getBoundaries ()
+ local x, y = self:getPosition()
+ return x - 160, y - 100, x + 160, y + 100
end
-function Camera:translatePoints (...)
- local a = {...}
- local r = {}
- local x,y = 0,0
- for k,v in pairs(a) do
- if k%2 == 1 then
- table.insert(r, (v + x) * getScale())
- else
- table.insert(r, (v + y) * getScale())
- end
+function Camera:getBoundariesScaled ()
+ local x, y = self:getPositionScaled()
+ local width, height = love.graphics.getDimensions()
+ width = width / 2
+ height = height / 2
+ return x - width, y - height, x + width, y + height
+end
+
+-- TODO: Camera@scalePoints is left because PhysicalBody still uses it as love.graphics.scale is not used yet.
+function Camera:scalePoints (...)
+ local a, r, scale = {...}, {}, getScale()
+ for _,v in pairs(a) do
+ table.insert(r, v * scale)
end
return r
end