map select
This commit is contained in:
@@ -132,21 +132,24 @@ end
|
||||
|
||||
function scene:start()
|
||||
scene.super.start(self)
|
||||
|
||||
|
||||
self.optionsMenu:addMenuItem("Main Menu", function() Noble.transition(Menu) end)
|
||||
Noble.showFPS = false
|
||||
if scene.musicEnabled then
|
||||
scene.levelAudio:play(0)
|
||||
end
|
||||
end
|
||||
|
||||
function scene:enter()
|
||||
scene.super.enter(self)
|
||||
|
||||
local soundTable = playdate.sound.playingSources()
|
||||
for i=1, #soundTable do
|
||||
soundTable[i]:stop()
|
||||
end
|
||||
scene.buttonTimeout = 100
|
||||
|
||||
Noble.Input.setHandler(scene.inputHandler)
|
||||
|
||||
if scene.musicEnabled then
|
||||
scene.levelAudio:play(0)
|
||||
end
|
||||
local text =
|
||||
[[The drone is assembled and operational. We are ready for the mission.
|
||||
|
||||
@@ -226,6 +229,10 @@ function scene:update()
|
||||
self.tickTimer:remove()
|
||||
screenShake(100, 5)
|
||||
Noble.Input.setEnabled(false)
|
||||
playdate.timer.performAfterDelay(2500, function() -- Return to the start after failure
|
||||
Noble.Input.setEnabled(true)
|
||||
Noble.transition(DroneCardSelector, nil, Noble.Transition.SpotlightMask);
|
||||
end)
|
||||
return
|
||||
end
|
||||
|
||||
|
@@ -12,7 +12,10 @@ scene.inputHandler = {
|
||||
scene.menuConfirmSound:play(1)
|
||||
Noble.transition(Assemble)
|
||||
end,
|
||||
BButtonDown = function() end,
|
||||
BButtonDown = function()
|
||||
scene.menuBackSound:play(1)
|
||||
Noble.transition(MapSelector)
|
||||
end,
|
||||
downButtonDown = function()
|
||||
end,
|
||||
leftButtonDown = function()
|
||||
@@ -41,7 +44,9 @@ function scene:setValues()
|
||||
self.menuIndex = 1
|
||||
|
||||
self.aKey = Graphics.image.new("assets/sprites/buttons/A")
|
||||
self.bKey = Graphics.image.new("assets/sprites/buttons/B")
|
||||
scene.menuConfirmSound = playdate.sound.fileplayer.new("assets/audio/confirm")
|
||||
scene.menuBackSound = playdate.sound.fileplayer.new("assets/audio/back")
|
||||
|
||||
scene.menuSelSound = playdate.sound.fileplayer.new("assets/audio/menu_select")
|
||||
scene.menuSelSound:setVolume(0.5)
|
||||
@@ -64,12 +69,10 @@ end
|
||||
|
||||
function scene:enter()
|
||||
scene.super.enter(self)
|
||||
scene.cards = {
|
||||
DroneCard(0, 0, Drones[1]),
|
||||
DroneCard(0, 0, Drones[2]),
|
||||
DroneCard(0, 0, Drones[3]),
|
||||
DroneCard(0, 0, Drones[4]),
|
||||
}
|
||||
scene.cards = {}
|
||||
for i = 1, #Drones do
|
||||
scene.cards[i] = DroneCard(0, 0, Drones[i])
|
||||
end
|
||||
scene.paginator = PageSprite(200, 207)
|
||||
end
|
||||
|
||||
@@ -91,7 +94,7 @@ function scene:update()
|
||||
end
|
||||
|
||||
local x = 0
|
||||
for i = 1, 4 do
|
||||
for i = 1, #scene.cards do
|
||||
x = 29 + (339 + 16) * (i - 1)
|
||||
scene.cards[i]:moveTo(x + scene.currentX, 25)
|
||||
end
|
||||
@@ -101,12 +104,15 @@ function scene:update()
|
||||
Noble.Text.draw("Assemble", 333, 210, Noble.Text.ALIGN_LEFT, false, fontMed)
|
||||
end
|
||||
|
||||
self.bKey:draw(15, 207 + dy)
|
||||
Noble.Text.draw("Back", 33, 210, Noble.Text.ALIGN_LEFT, false, fontMed)
|
||||
|
||||
scene.paginator:moveTo(200, 207)
|
||||
end
|
||||
|
||||
function scene:exit()
|
||||
scene.super.exit(self)
|
||||
for i = 1, 4 do
|
||||
for i = 1, #scene.cards do
|
||||
scene.cards[i]:remove()
|
||||
end
|
||||
Noble.showFPS = false
|
||||
|
123
source/scenes/MapSelector.lua
Normal file
123
source/scenes/MapSelector.lua
Normal file
@@ -0,0 +1,123 @@
|
||||
MapSelector = {}
|
||||
class("MapSelector").extends(BaseScene)
|
||||
local scene = MapSelector
|
||||
local fontMed = Graphics.font.new('assets/fonts/onyx_9')
|
||||
local fontBig = Graphics.font.new('assets/fonts/opal_12')
|
||||
local elapsedTime = 0
|
||||
|
||||
function scene:init()
|
||||
playdate.graphics.setImageDrawMode(playdate.graphics.kDrawModeXOR)
|
||||
scene.super.init(self)
|
||||
scene.menuIndex = 1
|
||||
|
||||
self.aKey = Graphics.image.new("assets/sprites/buttons/A")
|
||||
self.bKey = Graphics.image.new("assets/sprites/buttons/B")
|
||||
|
||||
scene.menuConfirmSound = playdate.sound.fileplayer.new("assets/audio/confirm")
|
||||
scene.menuBackSound = playdate.sound.fileplayer.new("assets/audio/back")
|
||||
|
||||
scene.menuSelSound = playdate.sound.fileplayer.new("assets/audio/menu_select")
|
||||
scene.menuSelSound:setVolume(0.5)
|
||||
|
||||
scene.currentX = 0
|
||||
scene.targetX = 0
|
||||
end
|
||||
|
||||
function scene:start()
|
||||
scene.super.start(self)
|
||||
|
||||
Noble.showFPS = false
|
||||
|
||||
self.optionsMenu:addMenuItem("Main Menu", function() Noble.transition(Menu) end)
|
||||
end
|
||||
|
||||
|
||||
function scene:enter()
|
||||
scene.super.enter(self)
|
||||
scene.cards = {}
|
||||
for i = 1, #Maps do
|
||||
scene.cards[i] = MapCard(0, 0, Maps[i])
|
||||
end
|
||||
end
|
||||
|
||||
function scene:update()
|
||||
scene.super.update(self)
|
||||
elapsedTime = elapsedTime + 1 / playdate.display.getRefreshRate()
|
||||
|
||||
local dy = 2 * math.sin(20 * elapsedTime)
|
||||
|
||||
local speed = 40
|
||||
if math.abs(scene.targetX - scene.currentX) < speed then
|
||||
scene.currentX = scene.targetX
|
||||
else
|
||||
scene.currentX = scene.currentX + speed * ((scene.targetX > scene.currentX) and 1 or -1)
|
||||
end
|
||||
|
||||
local x = 0
|
||||
for i = 1, #scene.cards do
|
||||
x = 0 + (339 + 16) * (i - 1)
|
||||
scene.cards[i]:moveTo(x + scene.currentX, 0)
|
||||
end
|
||||
|
||||
-- Bottom background
|
||||
if Maps[scene.menuIndex].locked == false then
|
||||
self.aKey:draw(315, 207 + dy)
|
||||
Noble.Text.draw("Select", 333, 210, Noble.Text.ALIGN_LEFT, false, fontMed)
|
||||
end
|
||||
|
||||
self.bKey:draw(15, 207 + dy)
|
||||
Noble.Text.draw("Back", 33, 210, Noble.Text.ALIGN_LEFT, false, fontMed)
|
||||
|
||||
Noble.Text.draw(string.upper(Maps[scene.menuIndex].name), 200, 210, Noble.Text.ALIGN_CENTER, false, fontBig)
|
||||
|
||||
|
||||
end
|
||||
|
||||
function scene:exit()
|
||||
scene.super.exit(self)
|
||||
for i = 1, #scene.cards do
|
||||
scene.cards[i]:remove()
|
||||
end
|
||||
Noble.showFPS = false
|
||||
playdate.graphics.setImageDrawMode(playdate.graphics.kDrawModeXOR)
|
||||
end
|
||||
|
||||
function scene:finish()
|
||||
scene.super.finish(self)
|
||||
for i = 1, #scene.cards do
|
||||
scene.cards[i]:remove()
|
||||
end
|
||||
playdate.display.setScale(1)
|
||||
end
|
||||
|
||||
scene.inputHandler = {
|
||||
AButtonDown = function()
|
||||
if Maps[scene.menuIndex].locked then
|
||||
return
|
||||
end
|
||||
scene.menuConfirmSound:play(1)
|
||||
Noble.transition(DroneCardSelector)
|
||||
end,
|
||||
BButtonDown = function()
|
||||
scene.menuBackSound:play(1)
|
||||
Noble.transition(Menu)
|
||||
end,
|
||||
leftButtonDown = function()
|
||||
if scene.menuIndex <= 1 then
|
||||
return
|
||||
end
|
||||
scene.menuSelSound:play(1)
|
||||
scene.targetX = scene.targetX + 355
|
||||
scene.menuIndex = scene.menuIndex - 1
|
||||
end,
|
||||
rightButtonDown = function()
|
||||
if scene.menuIndex >= #Maps then
|
||||
return
|
||||
end
|
||||
scene.menuSelSound:play(1)
|
||||
scene.targetX = scene.targetX - 355
|
||||
scene.menuIndex = scene.menuIndex + 1
|
||||
end,
|
||||
upButtonDown = function()
|
||||
end,
|
||||
}
|
@@ -106,13 +106,13 @@ end
|
||||
|
||||
function scene:exit()
|
||||
scene.super.exit(self)
|
||||
scene.levelAudio:stop()
|
||||
-- scene.levelAudio:stop()
|
||||
self.sequence = Sequence.new():from(self.menuY):to(self.menuYTo, 0.5, Ease.inSine)
|
||||
self.sequence:start()
|
||||
end
|
||||
|
||||
function scene:setupMenu(__menu)
|
||||
__menu:addItem("Start", function() Noble.transition(DroneCardSelector, nil, Noble.Transition.DipToWhite) end)
|
||||
__menu:addItem("Start", function() Noble.transition(MapSelector, nil, Noble.Transition.DipToWhite) end)
|
||||
__menu:addItem("Tutorial", function()
|
||||
local debug = Noble.Settings.get("debug")
|
||||
if debug then
|
||||
|
Reference in New Issue
Block a user