diff options
author | Aki <nthirtyone@gmail.com> | 2016-05-22 20:05:01 +0200 |
---|---|---|
committer | Aki <nthirtyone@gmail.com> | 2016-05-22 20:05:01 +0200 |
commit | 21f09f86852d7b7b033057cb1c86e06e74acb7d5 (patch) | |
tree | 787c2ccfbb795c21a777335bdd0295e26cbbc9be /camera.lua | |
parent | 13e368bc2c35c35369a1f6bf76778d88cae240da (diff) | |
download | roflnauts-21f09f86852d7b7b033057cb1c86e06e74acb7d5.zip roflnauts-21f09f86852d7b7b033057cb1c86e06e74acb7d5.tar.gz roflnauts-21f09f86852d7b7b033057cb1c86e06e74acb7d5.tar.bz2 |
Debug draw upgrade
Diffstat (limited to 'camera.lua')
-rw-r--r-- | camera.lua | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -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 |