summaryrefslogtreecommitdiff
path: root/client/camera.lua
diff options
context:
space:
mode:
Diffstat (limited to 'client/camera.lua')
-rw-r--r--client/camera.lua16
1 files changed, 8 insertions, 8 deletions
diff --git a/client/camera.lua b/client/camera.lua
index 6309e38..528b45b 100644
--- a/client/camera.lua
+++ b/client/camera.lua
@@ -1,15 +1,15 @@
local coords = require"common.coords"
+local class = require"common.class"
-- in screen units
local screen_width, screen_height = love.graphics.getDimensions()
-- zoom is screen pixels per world unit
-local Camera = {}
-Camera.__index = Camera
-function Camera.make(pos,zoom)
- pos = pos or coords.Pos.make(0,0)
+local Camera = class()
+function Camera.make(cls,pos,zoom)
+ pos = pos or coords.Pos:make(0,0)
zoom = zoom or 30
- return setmetatable({pos=pos,zoom=zoom},Camera)
+ return setmetatable({pos=pos,zoom=zoom},cls)
end
function Camera.apply_trans(self)
love.graphics.origin()
@@ -21,7 +21,7 @@ function Camera.apply_trans(self)
love.graphics.translate(-self.pos.x,-self.pos.y)
end
-local screen_offset = coords.Pos.make(screen_width/2,screen_height/2)
+local screen_offset = coords.Pos:make(screen_width/2,screen_height/2)
function Camera.screen_to_world(self,pos)
return (pos-screen_offset)/self.zoom + self.pos
end
@@ -31,8 +31,8 @@ end
function Camera.extents(self)
-- returns top left and bottom right pos's in world coords
- return self:screen_to_world(coords.Pos.make(0,0)),
- self:screen_to_world(coords.Pos.make(screen_width,screen_height))
+ return self:screen_to_world(coords.Pos:make(0,0)),
+ self:screen_to_world(coords.Pos:make(screen_width,screen_height))
end