sonic-radiance/sonic-radiance.love/game/modules/subgames/init.lua
Kazhnuz 70ed18202d feat: backport code from bluestreak
It'll give us the following features
- Support for autorun in shoot-style maps
- Pause menu in subgames
- Chunk in shoot maps
- Rings
2020-08-16 10:52:00 +02:00

83 lines
2 KiB
Lua

Scene = require("core.modules.scenes")
local PlayStyle = Scene:extend()
local PauseMenu = require("game.modules.subgames.pause")
local TestWorld = require("game.modules.world.parent")
function PlayStyle:new(supportedLevels, missionfile)
PlayStyle.super.new(self)
self.timer = 0
self.assets:batchImport("game.modules.gui.assets")
self.assets:batchImport("game.modules.subgames.assets")
--self:loadMissionFile(supportedLevels, missionfile)
PauseMenu(self)
self:initWorld()
self:initMission()
self:initCharacters()
self:startLevel()
end
function PlayStyle:loadMissionFile(supportedLevels, missionfile)
self.mission = require("datas.gamedata.missions." .. missionfile)
self.assets:setMusic("assets/music/" .. self.mission.music)
end
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
function PlayStyle:update(dt)
PlayStyle.super.update(self, dt)
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.world:loadMap()
--self.assets:playMusic()
end
function PlayStyle:restartLevel()
self.world:reset()
end
function PlayStyle:exitLevel()
scenes.title()
end
return PlayStyle