modules/world: add a basic view dimension system
This commit is contained in:
parent
a046eb5a9c
commit
3c498f2d16
1 changed files with 20 additions and 1 deletions
|
@ -46,7 +46,8 @@ function CameraSystem:initViews()
|
|||
self.views = {}
|
||||
|
||||
self.views.list = {}
|
||||
self.views.width, self.views.height = core.screen:getDimensions()
|
||||
self.views.basewidth, self.views.baseheight = core.screen:getDimensions()
|
||||
self.views.width, self.views.height = self:getViewsDimensions()
|
||||
end
|
||||
|
||||
-- INFO FUNCTIONS
|
||||
|
@ -60,6 +61,23 @@ function CameraSystem:haveView()
|
|||
return (self:getViewNumber() == 0)
|
||||
end
|
||||
|
||||
function CameraSystem:getViewsDimensions()
|
||||
local basewidth, baseheight = self.views.basewidth, self.views.baseheight
|
||||
local viewnumber = self:getViewNumber()
|
||||
|
||||
if (viewnumber <= 1) then
|
||||
return basewidth, baseheight
|
||||
elseif (viewnumber == 2) then
|
||||
if (self.verticalSplit) then
|
||||
return (basewidth/2), (baseheight)
|
||||
else
|
||||
return (basewidth), (baseheight/2)
|
||||
end
|
||||
else
|
||||
return (basewidth/2), (baseheight/2)
|
||||
end
|
||||
end
|
||||
|
||||
-- WRAPPER and UTILS
|
||||
-- Access data from the views
|
||||
|
||||
|
@ -72,6 +90,7 @@ function CameraSystem:addView(x, y)
|
|||
-- to target a specific object
|
||||
|
||||
table.insert(self.views.list, view)
|
||||
self.views.width, self.views.height = self:getViewsDimensions()
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue