sonic-bluestreak/sonic-boost.love/scenes/subgame/sonic-boost/init.lua

91 lines
2.1 KiB
Lua

local Scene = require "core.modules.scenes"
local BoostLevel = Scene:extend()
local Controller = require "scenes.subgame.sonic-boost.controller"
function BoostLevel:new()
BoostLevel.super.new(self)
self.controller = Controller()
self:register()
end
function BoostLevel: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 BoostLevel:initMission(levelid)
self:getLevelData(levelid)
self.mission = {}
self.mission.timer = 0
self.mission.completed = false
end
function BoostLevel:startMission()
self.initiated = true
end
function BoostLevel: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 BoostLevel:update(dt)
self.controller:update(dt)
end
function BoostLevel:draw()
self.controller:draw()
end
function BoostLevel:resetFont()
self.assets.fonts["text"]:set()
end
function BoostLevel:restartLevel()
self:new(self.levelid, self.character)
end
function BoostLevel:exitLevel()
Gamestate.switch(Scenes.options)
end
function BoostLevel:leave()
self.controller:destroy()
self.controller = nil
collectgarbage()
end
return BoostLevel