feat: add a playstyle base scene

This commit is contained in:
Kazhnuz 2019-12-28 21:51:41 +01:00
parent 63c54525f6
commit 8b42722520
5 changed files with 150 additions and 20 deletions

View file

@ -0,0 +1,16 @@
return {
["textures"] = {
{"shadow", "assets/sprites/shadow.png"}
},
["sprites"] = {
{"ring", "assets/sprites/items/ring"}
},
["imagefonts"] = {
{"menu", "assets/gui/fonts/SA2font"}
},
["sfx"] = {
{"navigate", "assets/sfx/menu/select.wav"},
{"confirm", "assets/sfx/menu/validate.wav"},
{"cancel", "assets/sfx/menu/cancel.wav"},
}
}

View file

@ -0,0 +1,57 @@
Scene = require("core.modules.scenes")
local PlayStyle = Scene:extend()
local PauseMenu = require("game.modules.playstyle.pause")
local TestWorld = require("game.modules.world.parent")
function PlayStyle:new(playerNumber, cameraMode)
local playerNumber = playerNumber or 1
local cameraMode = cameraMode or "split"
PlayStyle.super.new(self)
self.timer = 0
self.assets:batchImport("game.modules.playstyle.assets")
PauseMenu(self)
self:initWorld()
end
function PlayStyle:initWorld()
TestWorld(self)
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:restartLevel()
end
function PlayStyle:exitLevel()
scenes.title()
end
return PlayStyle

View file

@ -0,0 +1,67 @@
local ListBox = require "core.modules.menusystem.listbox"
local PauseMenu = ListBox:extend()
local Widget = require "core.modules.menusystem.widgets"
local ResumeWidget = Widget.Text:extend()
local RestartWidget = Widget.Text:extend()
local ExitWidget = Widget.Text:extend()
function PauseMenu:new(playstyle)
local height, width, x, y
height = 72
width = 128
x = 424/2 - width/2
y = 240/2 - height/2
PauseMenu.super.new(self, playstyle.menusystem, "pauseMenu", x, y, width, height, 3)
self.playstyle = playstyle
self:setSound(self.playstyle.assets.sfx["navigate"])
self.isActive = false
self.isVisible = false
local font = self.playstyle.assets.fonts["menu"]
ResumeWidget(self, font)
RestartWidget(self, font)
ExitWidget(self, font)
end
function PauseMenu:draw()
PauseMenu.super.draw(self)
end
--- MENU WIDGETS
function ResumeWidget:new(menu, font)
ResumeWidget.super.new(self, menu, font, "resume")
end
function ResumeWidget:action()
self.menu.isActive = false
self.menu.isVisible = false
self.menu.playstyle.world.isActive = true
self.menu.playstyle.assets.isActive = true
self.menu.playstyle:flushKeys()
end
function RestartWidget:new(menu, font)
ResumeWidget.super.new(self, menu, font, "restart")
end
function RestartWidget:action()
self.menu.playstyle:flushKeys()
self.menu.playstyle:restartLevel()
end
function ExitWidget:new(menu, font)
ExitWidget.super.new(self, menu, font, "exit")
end
function ExitWidget:action()
self.menu.playstyle:exitLevel()
end
return PauseMenu

View file

@ -1,17 +1,5 @@
return {
["textures"] = {
{"shadow", "assets/sprites/shadow.png"}
},
["sprites"] = {
{"sonic", "assets/sprites/characters/sonic"},
{"ring", "assets/sprites/items/ring"}
},
["imagefonts"] = {
--{"medium", "assets/fonts/medium"}
},
["sfx"] = {
--{"navigate", "assets/sfx/menu_move.mp3"},
--{"confirm", "assets/sfx/menu_confirm.mp3"},
--{"cancel", "assets/sfx/menu_error.mp3"},
{"sonic", "assets/sprites/characters/sonic"}
}
}

View file

@ -21,8 +21,8 @@
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
]]
local Scene = require "core.modules.scenes"
local MovePlayer = Scene:extend()
local PlayStyle = require "game.modules.playstyle"
local MovePlayer = PlayStyle:extend()
local TestWorld = require "game.modules.world.parent"
local ShootWorld = require "game.modules.world.shoot"
@ -32,17 +32,19 @@ function MovePlayer:new(playerNumber, cameraMode)
local playerNumber = playerNumber or 1
local cameraMode = cameraMode or "split"
MovePlayer.super.new(self)
MovePlayer.super.new(self, playerNumber, cameraMode)
self.assets:batchImport("scenes.test_scene.assets")
ShootWorld(self, "coast")
--BattleWorld(self, "ebeach")
--TestWorld(self)
self.world:setPlayerNumber(playerNumber)
self.world.cameras:setMode(cameraMode)
self.world:loadMap()
end
function MovePlayer:initWorld()
--ShootWorld(self, "coast")
--BattleWorld(self, "ebeach")
TestWorld(self)
end
return MovePlayer