scenes/levels: fuse map update and draw functions

This commit is contained in:
Kazhnuz 2019-03-03 13:38:41 +01:00
parent ecaabd4814
commit 314cfc241d
2 changed files with 17 additions and 12 deletions

View File

@ -86,11 +86,9 @@ end
-- UPDATE FUNCTIONS
function Level:update(dt)
self:updateMap(dt)
if (self.pause == false) then
self:updatePlayerSystem(dt)
self:worldUpdate(dt)
self:updateWorld(dt)
assets:update(dt)
self:updateCamera(dt)
end
@ -105,14 +103,8 @@ function Level:draw(dt)
-- Ona attache puis détache la caméra pour dessiner le monde, afin que celui
-- reste "fixe" tandis que le jouer bouge.
self:floorCameraCoord()
self:drawBackgroundColor()
self.camera:attach()
self:drawWorld()
self:drawMap()
self:drawCollisions()
self:worldDraw()
self.camera:detach()
if (self.pause == false) then
self:drawHUD()
end

View File

@ -106,7 +106,12 @@ function Level:countEntities()
return self.entities:countItems()
end
function Level:worldUpdate(dt)
function Level:updateWorld(dt)
self:updateEntities(dt)
self:updateMap(dt)
end
function Level:updateEntities(dt)
--l,t,w,h = l or 0, t or 0, w or self.width, h or self.height
local visibleThings, len = self:getVisibleEntities()
--table.sort(visibleThings, sortByUpdateOrder)
@ -118,7 +123,15 @@ function Level:worldUpdate(dt)
self.activeObjects = len
end
function Level:worldDraw(dt)
function Level:drawWorld()
self:drawBackgroundColor()
self.camera:attach()
self:drawMap()
self:drawEntities()
self.camera:detach()
end
function Level:drawEntities()
--l,t,w,h = l or 0, t or 0, w or self.width, h or self.height
local visibleThings, len = self:getVisibleEntities()
--table.sort(visibleThings, sortByUpdateOrder)