summaryrefslogtreecommitdiffhomepage
path: root/camera.lua
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2016-05-22 20:05:01 +0200
committerAki <nthirtyone@gmail.com>2016-05-22 20:05:01 +0200
commit21f09f86852d7b7b033057cb1c86e06e74acb7d5 (patch)
tree787c2ccfbb795c21a777335bdd0295e26cbbc9be /camera.lua
parent13e368bc2c35c35369a1f6bf76778d88cae240da (diff)
downloadroflnauts-21f09f86852d7b7b033057cb1c86e06e74acb7d5.zip
roflnauts-21f09f86852d7b7b033057cb1c86e06e74acb7d5.tar.gz
roflnauts-21f09f86852d7b7b033057cb1c86e06e74acb7d5.tar.bz2
Debug draw upgrade
Diffstat (limited to 'camera.lua')
-rw-r--r--camera.lua25
1 files changed, 25 insertions, 0 deletions
diff --git a/camera.lua b/camera.lua
index cb367a3..04590d1 100644
--- a/camera.lua
+++ b/camera.lua
@@ -43,6 +43,10 @@ function Camera:getPosition ()
return self.x, self.y
end
+function Camera:getPositionScaled ()
+ return self.x*self.scale, self.y*self.scale
+end
+
-- Destination
function Camera:setDestination (x, y)
local x = x or 0
@@ -53,6 +57,27 @@ end
function Camera:getDestination ()
return self.dest_x, self.dest_y
end
+
+-- Translate points
+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
+end
+
+function Camera:translatePoints(...)
+ local a = {...}
+ local r = {}
+ local x,y = self:getOffsets()
+ for k,v in pairs(a) do
+ if k%2 == 1 then
+ table.insert(r, (v + x) * self.scale)
+ else
+ table.insert(r, (v + y) * self.scale)
+ end
+ end
+ return r
+end
-- Shake it
-- Really bad script, but for now it works