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

View file

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