diff options
author | ubq323 <ubq323@ubq323.website> | 2023-02-03 19:37:28 +0000 |
---|---|---|
committer | ubq323 <ubq323@ubq323.website> | 2023-02-03 19:51:07 +0000 |
commit | 1ebd7d9b7b62c8e05d527611a1944ed1a876b890 (patch) | |
tree | cfc5ddf3fc15985c4369aa12d56de5fa8d6fc7e5 /client/camera.lua | |
parent | ec6a391cb9cf0c0feac0fe3615a59cc7cb6db2d5 (diff) |
debug drawing change, zoom clamping, partial refactoring of class mechanisms to allow inheritance, minor refactor of noise generator, changes to temp worldgen, rework of class constructor mechanism
Diffstat (limited to 'client/camera.lua')
-rw-r--r-- | client/camera.lua | 16 |
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 |