From 48aa0a3eabeabdaecc53e9b2f77ec18adeaea355 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Thu, 30 May 2019 13:27:41 +0200 Subject: [PATCH] gamecore/scene: put world wrapper inside the scene --- gamecore/modules/scenes.lua | 12 ++++++++++++ gamecore/scenemanager.lua | 8 ++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/gamecore/modules/scenes.lua b/gamecore/modules/scenes.lua index c59af76..5fbdc06 100644 --- a/gamecore/modules/scenes.lua +++ b/gamecore/modules/scenes.lua @@ -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 diff --git a/gamecore/scenemanager.lua b/gamecore/scenemanager.lua index 4119ab2..bbb9b08 100644 --- a/gamecore/scenemanager.lua +++ b/gamecore/scenemanager.lua @@ -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