restructured folder

This commit is contained in:
lustlion
2022-02-12 11:36:43 +01:00
parent e51905de67
commit 8ddf3610ac
33 changed files with 49 additions and 44 deletions

21
code/camera.lua Normal file
View 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