From 21f09f86852d7b7b033057cb1c86e06e74acb7d5 Mon Sep 17 00:00:00 2001 From: Aki Date: Sun, 22 May 2016 20:05:01 +0200 Subject: Debug draw upgrade --- camera.lua | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'camera.lua') 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 -- cgit v1.1