gamecore/scene: put world wrapper inside the scene

This commit is contained in:
Kazhnuz 2019-05-30 13:27:41 +02:00
parent df4d264c21
commit 48aa0a3eab
2 changed files with 14 additions and 6 deletions

View file

@ -63,6 +63,12 @@ function Scene:update(dt)
-- Empty function, is just here to avoid crash
end
function Scene:updateWorld(dt)
if (self.world ~= nil) then
self.world:update(dt)
end
end
-- MOUSE FUNCTIONS
-- Make the scene support the pointer
@ -103,6 +109,12 @@ function Scene:draw()
end
function Scene:drawWorld(dt)
if (self.world ~= nil) then
self.world:draw()
end
end
-- INPUT FUNCTIONS
-- Handle inputs from keyboard/controllers

View file

@ -67,9 +67,7 @@ function SceneManager:update(dt)
self.currentScene:setKeys()
self.currentScene.assets:update(dt)
self.currentScene.menusystem:update(dt)
if (self.currentScene.world ~= nil) then
self.currentScene.world:update(dt)
end
self.currentScene:updateWorld(dt)
self.currentScene:update(dt)
end
end
@ -112,9 +110,7 @@ function SceneManager:draw()
if (self.currentScene ~= nil) then
self.currentScene:draw(dt)
self.currentScene.menusystem:draw()
if (self.currentScene.world ~= nil) then
self.currentScene.world:draw()
end
self.currentScene:drawWorld()
end
self.controller.screen:cease()
end