refactor(levels): register the world and manage it automatically
This commit is contained in:
parent
0474c8161a
commit
557de3b503
|
@ -60,13 +60,10 @@ end
|
||||||
|
|
||||||
function Level:update(dt)
|
function Level:update(dt)
|
||||||
local keys = self.sources[1].keys
|
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
|
if keys["start"].isPressed then
|
||||||
|
self.world:setActivity(self.pause)
|
||||||
|
self.assets:setActivity(self.pause)
|
||||||
self.pause = (self.pause == false)
|
self.pause = (self.pause == false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -77,9 +74,6 @@ end
|
||||||
function Level:draw(dt)
|
function Level:draw(dt)
|
||||||
utils.graphics.resetColor()
|
utils.graphics.resetColor()
|
||||||
|
|
||||||
self.camera:floorCoord()
|
|
||||||
self.world:draw()
|
|
||||||
|
|
||||||
if (self.pause == false) then
|
if (self.pause == false) then
|
||||||
self.playermanager:drawHUD()
|
self.playermanager:drawHUD()
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,6 +17,9 @@ function World:new(scene, mapfile)
|
||||||
self.backcolor = self.map.backgroundcolor or {0, 0, 0}
|
self.backcolor = self.map.backgroundcolor or {0, 0, 0}
|
||||||
|
|
||||||
self.activeObjects = 0
|
self.activeObjects = 0
|
||||||
|
self:register()
|
||||||
|
|
||||||
|
self.isActive = true
|
||||||
end
|
end
|
||||||
|
|
||||||
function World:load()
|
function World:load()
|
||||||
|
@ -58,8 +61,10 @@ end
|
||||||
-- All update functions
|
-- All update functions
|
||||||
|
|
||||||
function World:update(dt)
|
function World:update(dt)
|
||||||
|
self.scene.playermanager:update(dt)
|
||||||
self:updateEntities(dt)
|
self:updateEntities(dt)
|
||||||
self:updateMap(dt)
|
self:updateMap(dt)
|
||||||
|
self.scene.camera:update(dt)
|
||||||
end
|
end
|
||||||
|
|
||||||
function World:updateEntities(dt)
|
function World:updateEntities(dt)
|
||||||
|
@ -84,6 +89,7 @@ end
|
||||||
function World:draw()
|
function World:draw()
|
||||||
-- Ona attache puis détache la caméra pour dessiner le monde, afin que celui
|
-- Ona attache puis détache la caméra pour dessiner le monde, afin que celui
|
||||||
-- reste "fixe" tandis que le jouer bouge.
|
-- reste "fixe" tandis que le jouer bouge.
|
||||||
|
self.scene.camera:floorCoord()
|
||||||
self:drawBackgroundColor()
|
self:drawBackgroundColor()
|
||||||
self.scene.camera:attach()
|
self.scene.camera:attach()
|
||||||
self:drawMap()
|
self:drawMap()
|
||||||
|
|
Loading…
Reference in New Issue