sonic-bluestreak/sonic-bluestreak.love/game/modules/subgames/init.lua

91 lines
2.1 KiB
Lua
Raw Permalink Normal View History

local Scene = require("game.scenes")
2019-12-28 21:51:41 +01:00
local PlayStyle = Scene:extend()
local PauseMenu = require("game.modules.subgames.pause")
local TestWorld = require("game.modules.subgames.world.parent")
2019-12-28 21:51:41 +01:00
function PlayStyle:new(supportedLevels, missionfile)
2019-12-28 21:51:41 +01:00
PlayStyle.super.new(self)
self.timer = 0
self.assets:batchImport("assets.subgames")
--self:loadMissionFile(supportedLevels, missionfile)
2019-12-28 21:51:41 +01:00
PauseMenu(self)
self:initWorld()
self:initMission()
self:initCharacters()
self.haveStarted = false
2019-12-28 21:51:41 +01:00
end
2020-01-26 15:30:00 +01:00
function PlayStyle:loadMissionFile(supportedLevels, missionfile)
self.mission = require("datas.gamedata.missions." .. missionfile)
self.assets:setMusic("assets/music/" .. self.mission.music)
end
2019-12-28 21:51:41 +01:00
function PlayStyle:initWorld()
TestWorld(self)
end
function PlayStyle:initMission()
-- NOTHING
end
function PlayStyle:initCharacters()
self.world:setPlayerNumber(1)
self.world.cameras:setMode("split")
end
function PlayStyle:getCharacterName(charID)
return self.characterList[charID]
end
2019-12-28 21:51:41 +01:00
function PlayStyle:update(dt)
if (self.haveStarted) then
PlayStyle.super.update(self, dt)
self:updatePauseMenus(dt)
else
self:startLevel()
end
end
function PlayStyle:updatePauseMenus(dt)
2019-12-28 21:51:41 +01:00
if self.menusystem.menus["pauseMenu"].isActive == false then
self.timer = self.timer + dt
end
local keys = self:getKeys(1);
if keys["start"].isPressed then
if not (self.menusystem.menus["pauseMenu"].isActive) then
self.menusystem.menus["pauseMenu"].isActive = true
self.menusystem.menus["pauseMenu"].isVisible = true
self.menusystem.menus["pauseMenu"]:getFocus()
self.assets.isActive = false
self.world.isActive = false
else
self.menusystem.menus["pauseMenu"].isActive = false
self.menusystem.menus["pauseMenu"].isVisible = false
self.assets.isActive = true
self.world.isActive = true
end
end
end
function PlayStyle:startLevel()
self.haveStarted = true
self.world:loadMap()
--self.assets:playMusic()
end
2019-12-28 21:51:41 +01:00
function PlayStyle:restartLevel()
self.world:reset()
2019-12-28 21:51:41 +01:00
end
function PlayStyle:exitLevel()
scenes.menus.title()
2019-12-28 21:51:41 +01:00
end
return PlayStyle