From b3bbde12326d7523feed48b8c0500da0d5b74e44 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 10 Mar 2019 13:26:20 +0100 Subject: [PATCH] scenes/battlesystem: merge battlesystem controller with scene object --- .../scenes/battlesystem/init.lua | 52 ++++++++++++++----- 1 file changed, 40 insertions(+), 12 deletions(-) diff --git a/sonic-radiance.love/scenes/battlesystem/init.lua b/sonic-radiance.love/scenes/battlesystem/init.lua index 19a52e1..5597f4d 100644 --- a/sonic-radiance.love/scenes/battlesystem/init.lua +++ b/sonic-radiance.love/scenes/battlesystem/init.lua @@ -1,15 +1,36 @@ -local BattleSystem = {} -local Controller = require "scenes.battlesystem.controller" +local Scene = require "core.modules.scenes" -function BattleSystem:enter() - self.controller = Controller() - --self.background = love.graphics.newImage("assets/background/testbackground.png") +local BattleSystem = Scene:extend() + +local BattleArena = require "scenes.battlesystem.controller.battlearena" +local ActorManager = require "scenes.battlesystem.controller.actors" +local HUD = require "scenes.battlesystem.controller.hud" +local Cursor = require "scenes.battlesystem.controller.cursor" +local MenuSystem = require "scenes.battlesystem.controller.menu" + + +function BattleSystem:new() + self:initManagers() +end + +function BattleSystem:initManagers() + --self.loader = Loader() + self.datas = {} + self.battlearena = BattleArena(self) + self.actormanager = ActorManager(self) + self.hud = HUD(self) + self.cursor = Cursor(self) + self.menusystem = MenuSystem(self) end function BattleSystem:update(dt) - game:update(dt) - game.input:update(dt) - self.controller:update(dt) + self.hud:update(dt) + self.battlearena:update(dt) + self.cursor:update(dt) + self.assets:update(dt) + + self.actormanager:update(dt) + self.menusystem:update(dt) end function BattleSystem:draw() @@ -17,13 +38,20 @@ function BattleSystem:draw() love.graphics.setColor(1, 1, 1, 1) love.graphics.rectangle("fill", 0, 0, 424, 240) --love.graphics.draw(self.background, 0, 0) - self.controller:draw() + self.battlearena:draw() + self.cursor:drawBottom() + self.battlearena:drawEntities() + self.cursor:drawTop() + self.hud:draw() + self.actormanager:draw() + + self.menusystem:draw(dt) --CScreen:cease() end -function BattleSystem:leave() - self.controller:destroy() - self.controller = nil +function BattleSystem:exit() + self.world:destroy() + self.battlearena = nil collectgarbage() end