refactor(levels): register the world and manage it automatically

This commit is contained in:
Kazhnuz 2019-06-17 11:40:26 +02:00
parent 0474c8161a
commit 557de3b503
2 changed files with 8 additions and 8 deletions

View File

@ -60,13 +60,10 @@ end
function Level:update(dt)
local keys = self.sources[1].keys
if (self.pause == false) then
self.playermanager:update(dt)
self.world:update(dt)
self.camera:update(dt)
end
if keys["start"].isPressed then
self.world:setActivity(self.pause)
self.assets:setActivity(self.pause)
self.pause = (self.pause == false)
end
end
@ -77,9 +74,6 @@ end
function Level:draw(dt)
utils.graphics.resetColor()
self.camera:floorCoord()
self.world:draw()
if (self.pause == false) then
self.playermanager:drawHUD()
end

View File

@ -17,6 +17,9 @@ function World:new(scene, mapfile)
self.backcolor = self.map.backgroundcolor or {0, 0, 0}
self.activeObjects = 0
self:register()
self.isActive = true
end
function World:load()
@ -58,8 +61,10 @@ end
-- All update functions
function World:update(dt)
self.scene.playermanager:update(dt)
self:updateEntities(dt)
self:updateMap(dt)
self.scene.camera:update(dt)
end
function World:updateEntities(dt)
@ -84,6 +89,7 @@ end
function World:draw()
-- Ona attache puis détache la caméra pour dessiner le monde, afin que celui
-- reste "fixe" tandis que le jouer bouge.
self.scene.camera:floorCoord()
self:drawBackgroundColor()
self.scene.camera:attach()
self:drawMap()