Camera = { pos = {x = 0, y = 0}, width = 0, height = 0 } function Camera:CenterAt(x,y,cx,cy) self.pos.x = x-self.width/(2*game.scale) self.pos.y = y-self.height/(2*game.scale) cx = cx - self.width cy = cy - self.height if not (cx == nil or cy == nil) then if self.pos.x > cx then self.pos.x = cx end if self.pos.y > cy then self.pos.y = cy end if self.pos.x < 0 then self.pos.x = 0 end if self.pos.y < 0 then self.pos.y = 0 end end self.pos.x = math.floor(self.pos.x) self.pos.y = math.floor(self.pos.y) end function Camera:ScreenAt(x,y) self.pos.x = math.floor(x/self.width)*self.width self.pos.y = math.floor(y/self.height)*self.height end