scenes/boost: kill off the scene controller object
It's not needed with the new scene system
This commit is contained in:
parent
ca22b918b0
commit
d199c73f64
2 changed files with 80 additions and 169 deletions
|
@ -1,163 +0,0 @@
|
|||
local Controller = Object:extend()
|
||||
--local GUI = require "modules.gui"
|
||||
local Assets = require "core.modules.assets"
|
||||
|
||||
local folder = "scenes.subgame.sonic-boost.controller."
|
||||
|
||||
local HUD = require(folder .. "hud")
|
||||
local Background = require(folder .. "background")
|
||||
local Camera = require(folder .. "camera")
|
||||
local World = require(folder .. "world")
|
||||
--local PauseMenu = require(folder .. "pause")
|
||||
|
||||
local CharacterManager = require(folder .. "characters")
|
||||
|
||||
local zoneDatas = require "datas.subgame.sonic-boost.levels.zones"
|
||||
|
||||
local LoadAssets = require(folder .. "loader")
|
||||
|
||||
function Controller:new(levelid, character)
|
||||
self:initMission()
|
||||
|
||||
self.assets = Assets()
|
||||
--self.gui = GUI()
|
||||
LoadAssets(self)
|
||||
|
||||
self:initManagers()
|
||||
|
||||
self:resetFont()
|
||||
|
||||
self.levelid = levelid
|
||||
self.character = character
|
||||
|
||||
if self.datas.music ~= nil then
|
||||
local filepath = "assets/music/" .. self.datas.music .. ".mp3"
|
||||
print(filepath)
|
||||
self.assets:setMusic(filepath)
|
||||
self.assets:playMusic()
|
||||
end
|
||||
|
||||
self.pause = false
|
||||
self.initiated = false
|
||||
|
||||
self.world:loadWorld()
|
||||
|
||||
self.characters:newPlayer("sonic", 2)
|
||||
--self.characters:newDummy("sonic", 0)
|
||||
--self.characters:newDummy("sonic", 1)
|
||||
--self.characters:newDummy("sonic", 3)
|
||||
--self.characters:newDummy("sonic", 4)
|
||||
end
|
||||
|
||||
function Controller:restartLevel()
|
||||
self:new(self.levelid, self.character)
|
||||
end
|
||||
|
||||
function Controller:exitLevel()
|
||||
Gamestate.switch(Scenes.options)
|
||||
end
|
||||
|
||||
function Controller:initManagers()
|
||||
--self.loader = Loader()
|
||||
self.world = World(self)
|
||||
self.hud = HUD(self)
|
||||
self.camera = Camera(self, 0, 0)
|
||||
self.background = Background(self)
|
||||
self.characters = CharacterManager(self)
|
||||
--self.pausemenu = PauseMenu(self)
|
||||
end
|
||||
|
||||
function Controller:destroy()
|
||||
self.world:destroy()
|
||||
|
||||
|
||||
self.world = nil
|
||||
self.hud = nil
|
||||
self.camera = nil
|
||||
self.background = nil
|
||||
self.characters = nil
|
||||
--self.pausemenu = nil
|
||||
|
||||
self.assets:clear()
|
||||
end
|
||||
|
||||
function Controller:initMission(levelid)
|
||||
self:getLevelData(levelid)
|
||||
|
||||
self.mission = {}
|
||||
self.mission.timer = 0
|
||||
self.mission.completed = false
|
||||
end
|
||||
|
||||
function Controller:startMission()
|
||||
self.initiated = true
|
||||
end
|
||||
|
||||
function Controller:getLevelData(file)
|
||||
local file = file or "testlevel.test1"
|
||||
local level = require("datas.subgame.sonic-boost.levels." .. file)
|
||||
|
||||
self.zone = level.datas.zone
|
||||
|
||||
local zone_data = zoneDatas[self.zone]
|
||||
local bypass_data = level.datas.bypass_data
|
||||
|
||||
self.datas = {}
|
||||
|
||||
if (level.datas.bypass_zone) then
|
||||
self.datas.name = bypass_data.name or zone_data.name
|
||||
self.datas.borders = bypass_data.borders or zone_data.borders
|
||||
self.datas.tiles = bypass_data.tiles or zone_data.tiles
|
||||
self.datas.background = bypass_data.background or zone_data.background
|
||||
self.datas.music = bypass_data.music or zone_data.music
|
||||
else
|
||||
self.datas = zone_data
|
||||
end
|
||||
|
||||
self.layout = level.layout
|
||||
self.parts = level.parts
|
||||
self.endless_parts = level.endless_parts
|
||||
|
||||
self.missiondata = level.datas.missiondata
|
||||
|
||||
end
|
||||
|
||||
function Controller:update(dt)
|
||||
|
||||
if self.pause == false then
|
||||
self.assets:update(dt)
|
||||
self.mission.timer = self.mission.timer + dt
|
||||
self.world:update(dt)
|
||||
self.camera:update(dt)
|
||||
else
|
||||
--self.pausemenu:update(dt)
|
||||
end
|
||||
|
||||
if core.input.keys["start"].isPressed then
|
||||
self.pause = (self.pause == false)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function Controller:draw()
|
||||
|
||||
self.background:draw()
|
||||
|
||||
self.camera.view:attach()
|
||||
self.world:draw()
|
||||
self.camera.view:detach()
|
||||
|
||||
utils.graphics.resetColor()
|
||||
self.hud:draw()
|
||||
|
||||
if self.pause == true then
|
||||
--self.pausemenu:draw(dt)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function Controller:resetFont()
|
||||
self.assets.fonts["text"]:set()
|
||||
end
|
||||
|
||||
return Controller
|
|
@ -1,10 +1,53 @@
|
|||
local Scene = require "core.modules.scenes"
|
||||
local BoostLevel = Scene:extend()
|
||||
local Controller = require "scenes.subgame.sonic-boost.controller"
|
||||
|
||||
local Assets = require "core.modules.assets"
|
||||
|
||||
local folder = "scenes.subgame.sonic-boost.controller."
|
||||
|
||||
local HUD = require(folder .. "hud")
|
||||
local Background = require(folder .. "background")
|
||||
local Camera = require(folder .. "camera")
|
||||
local World = require(folder .. "world")
|
||||
--local PauseMenu = require(folder .. "pause")
|
||||
|
||||
local CharacterManager = require(folder .. "characters")
|
||||
|
||||
local zoneDatas = require "datas.subgame.sonic-boost.levels.zones"
|
||||
|
||||
local LoadAssets = require(folder .. "loader")
|
||||
|
||||
function BoostLevel:new()
|
||||
BoostLevel.super.new(self)
|
||||
self.controller = Controller()
|
||||
self:initMission()
|
||||
|
||||
self.assets = Assets()
|
||||
LoadAssets(self)
|
||||
|
||||
self:initManagers()
|
||||
|
||||
self:resetFont()
|
||||
|
||||
self.levelid = nil
|
||||
self.character = nil
|
||||
|
||||
if self.datas.music ~= nil then
|
||||
local filepath = "assets/music/" .. self.datas.music .. ".mp3"
|
||||
print(filepath)
|
||||
self.assets:setMusic(filepath)
|
||||
self.assets:playMusic()
|
||||
end
|
||||
|
||||
self.pause = false
|
||||
self.initiated = false
|
||||
|
||||
self.world:loadWorld()
|
||||
|
||||
self.characters:newPlayer("sonic", 2)
|
||||
--self.characters:newDummy("sonic", 0)
|
||||
--self.characters:newDummy("sonic", 1)
|
||||
--self.characters:newDummy("sonic", 3)
|
||||
--self.characters:newDummy("sonic", 4)
|
||||
|
||||
self:register()
|
||||
end
|
||||
|
@ -61,11 +104,33 @@ function BoostLevel:getLevelData(file)
|
|||
end
|
||||
|
||||
function BoostLevel:update(dt)
|
||||
self.controller:update(dt)
|
||||
if self.pause == false then
|
||||
self.assets:update(dt)
|
||||
self.mission.timer = self.mission.timer + dt
|
||||
self.world:update(dt)
|
||||
self.camera:update(dt)
|
||||
else
|
||||
--self.pausemenu:update(dt)
|
||||
end
|
||||
|
||||
if core.input.keys["start"].isPressed then
|
||||
self.pause = (self.pause == false)
|
||||
end
|
||||
end
|
||||
|
||||
function BoostLevel:draw()
|
||||
self.controller:draw()
|
||||
self.background:draw()
|
||||
|
||||
self.camera.view:attach()
|
||||
self.world:draw()
|
||||
self.camera.view:detach()
|
||||
|
||||
utils.graphics.resetColor()
|
||||
self.hud:draw()
|
||||
|
||||
if self.pause == true then
|
||||
--self.pausemenu:draw(dt)
|
||||
end
|
||||
end
|
||||
|
||||
function BoostLevel:resetFont()
|
||||
|
@ -81,8 +146,17 @@ function BoostLevel:exitLevel()
|
|||
end
|
||||
|
||||
function BoostLevel:leave()
|
||||
self.controller:destroy()
|
||||
self.controller = nil
|
||||
self.world:destroy()
|
||||
|
||||
|
||||
self.world = nil
|
||||
self.hud = nil
|
||||
self.camera = nil
|
||||
self.background = nil
|
||||
self.characters = nil
|
||||
--self.pausemenu = nil
|
||||
|
||||
self.assets:clear()
|
||||
|
||||
collectgarbage()
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue