summaryrefslogtreecommitdiffhomepage
path: root/camera.lua
diff options
context:
space:
mode:
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