restructured folder
This commit is contained in:
21
code/camera.lua
Normal file
21
code/camera.lua
Normal file
@@ -0,0 +1,21 @@
|
||||
Camera = {
|
||||
pos = {x = 0, y = 0},
|
||||
width = 0,
|
||||
height = 0
|
||||
}
|
||||
|
||||
function Camera:ConfineToLevel()
|
||||
self.pos.x = math.max(0,math.min(self.pos.x,LevelData.Width-self.width/game.scale))
|
||||
self.pos.y = math.max(0,math.min(self.pos.y,LevelData.Height-self.height/game.scale))
|
||||
end
|
||||
|
||||
function Camera:positionCenterAt(x,y)
|
||||
self.pos.x = x-self.width/game.scale/2
|
||||
self.pos.y = y-self.height/game.scale/2
|
||||
self:ConfineToLevel()
|
||||
end
|
||||
|
||||
function Camera:positionAt(x,y)
|
||||
self.pos.x = math.floor((x/self.width)*self.width)
|
||||
self.pos.y = math.floor((y/self.height)*self.height)
|
||||
end
|
||||
Reference in New Issue
Block a user