redesign music and drone selection

This commit is contained in:
2024-06-12 01:22:12 +03:00
parent 43512c90c7
commit 025880c358
21 changed files with 198 additions and 15 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 989 B

View File

@@ -36,6 +36,7 @@ CollideGroups = {
Drones = {
{
id = 1,
name = "Quad FPV",
description =
"This is a quadrocopter with a camera on it. It's a good drone for beginners. It's easy to control and has a good battery life.",
@@ -45,6 +46,7 @@ Drones = {
full = Graphics.image.new("assets/sprites/assemble/1/8.png")
},
{
id = 2,
name = "Drone 2",
description = "This is a drone",
price = 200,
@@ -53,6 +55,7 @@ Drones = {
full = nil
},
{
id = 3,
name = "Drone 3",
description = "This is a drone",
price = 300,
@@ -61,6 +64,7 @@ Drones = {
full = nil
},
{
id = 4,
name = "Drone 4",
description = "This is a drone",
price = 400,
@@ -78,10 +82,13 @@ import "scripts/dangerSprite"
import "scripts/tankSprite"
import "scripts/progressBar"
import "scripts/selectionSprite"
import "scripts/DroneCard"
import "scripts/pageSprite"
import "scenes/BaseScene"
import 'scenes/Assemble'
import 'scenes/DroneSelection'
import 'scenes/DroneCardSelector'
import 'scenes/Menu'
import 'scenes/Game'
@@ -118,6 +125,6 @@ Noble.GameData.setup({
playdate.display.setRefreshRate(50)
Noble.showFPS = true
Noble.showFPS = false
Noble.new(Menu)

View File

@@ -8,6 +8,9 @@ local fontMed = Graphics.font.new('assets/fonts/onyx_9')
local allButtons = { "A", "B", "DOWN", "LEFT", "RIGHT", "UP" }
function scene:popCode(button)
if #scene.code == 0 then
return
end
scene.menuConfirmSound:stop()
if scene.tickTimer.paused then
scene.droneParts = scene:loadDrone(1, #scene.code)
@@ -35,7 +38,14 @@ function scene:popCode(button)
end
scene.inputHandler = {
AButtonDown = function() scene:popCode("A") end,
AButtonDown = function()
if #scene.code == 0 then
scene.menuConfirmSound:play(1)
Noble.transition(Game, nil, Noble.Transition.SpotlightMask)
else
scene:popCode("A")
end
end,
BButtonDown = function() scene:popCode("B") end,
downButtonDown = function() scene:popCode("DOWN") end,
leftButtonDown = function() scene:popCode("LEFT") end,
@@ -95,6 +105,11 @@ function scene:setValues()
scene.menuConfirmSound = playdate.sound.fileplayer.new("assets/audio/confirm")
self.aKey = Graphics.image.new("assets/sprites/buttons/A")
scene.musicEnabled = Noble.Settings.get("music")
scene.levelAudio = playdate.sound.fileplayer.new("assets/audio/assemble")
scene.levelAudio:setVolume(0.7)
end
function scene:init()
@@ -120,11 +135,19 @@ function scene:start()
scene.super.start(self)
self.optionsMenu:addMenuItem("Main Menu", function() Noble.transition(Menu) end)
Noble.showFPS = true
Noble.showFPS = false
end
function scene:enter()
scene.super.enter(self)
scene.buttonTimeout = 100
Noble.Input.setHandler(scene.inputHandler)
if scene.musicEnabled then
scene.levelAudio:play(0)
end
end
function round(number)
@@ -155,13 +178,6 @@ function scene:update()
yEnd = 100,
invert = false
})
scene.inputHandler = {
AButtonDown = function()
Noble.transition(Game, nil, Noble.Transition.SpotlightMask)
scene.menuConfirmSound:play(1)
end
}
Noble.Input.setHandler(scene.inputHandler)
self.aKey:draw(200, 170 + dy)
Noble.Text.draw("Start Mission", 218, 175, Noble.Text.ALIGN_LEFT, false, fontMed)
self.progressBar:remove()
@@ -210,7 +226,7 @@ end
function scene:exit()
scene.super.exit(self)
scene.levelAudio:stop()
Noble.showFPS = false
end

View File

@@ -0,0 +1,115 @@
DroneCardSelector = {}
class("DroneCardSelector").extends(BaseScene)
local scene = DroneCardSelector
local fontMed = Graphics.font.new('assets/fonts/onyx_9')
local elapsedTime = 0
scene.inputHandler = {
AButtonDown = function()
scene.menuConfirmSound:play(1)
Noble.transition(Assemble)
end,
BButtonDown = function() end,
downButtonDown = function()
end,
leftButtonDown = function()
if scene.menuIndex <= 1 then
return
end
scene.menuSelSound:play(1)
scene.targetX = scene.targetX + 355
scene.menuIndex = scene.menuIndex - 1
scene.paginator:set(scene.menuIndex)
end,
rightButtonDown = function()
if scene.menuIndex >= 4 then
return
end
scene.menuSelSound:play(1)
scene.targetX = scene.targetX - 355
scene.menuIndex = scene.menuIndex + 1
scene.paginator:set(scene.menuIndex)
end,
upButtonDown = function()
end,
}
function scene:setValues()
self.menuIndex = 1
self.aKey = Graphics.image.new("assets/sprites/buttons/A")
scene.menuConfirmSound = playdate.sound.fileplayer.new("assets/audio/confirm")
scene.menuSelSound = playdate.sound.fileplayer.new("assets/audio/menu_select")
scene.menuSelSound:setVolume(0.5)
scene.currentX = 0
scene.targetX = 0
end
function scene:init()
scene.super.init(self)
scene:setValues()
end
function scene:start()
scene.super.start(self)
self.optionsMenu:addMenuItem("Main Menu", function() Noble.transition(Menu) end)
Noble.showFPS = false
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.paginator = PageSprite(200, 207)
end
function scene:update()
scene.super.update(self)
if scene.cards == nil then
print("scene.cards is nil")
return
end
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, 4 do
x = 29 + (339 + 16) * (i - 1)
scene.cards[i]:moveTo(x + scene.currentX, 25)
end
if Drones[scene.menuIndex].locked == false then
self.aKey:draw(315, 207 + dy)
Noble.Text.draw("Assemble", 333, 210, Noble.Text.ALIGN_LEFT, false, fontMed)
end
scene.paginator:moveTo(200, 207)
end
function scene:exit()
scene.super.exit(self)
for i = 1, 4 do
scene.cards[i]:remove()
end
Noble.showFPS = false
end
function scene:finish()
scene.super.finish(self)
playdate.display.setScale(1)
end

View File

@@ -48,7 +48,7 @@ function scene:setValues()
scene.balebaSpawner = playdate.timer.new(10000)
scene.balebaSpawner.repeats = true
scene.levelAudio = playdate.sound.fileplayer.new("assets/audio/war")
scene.levelAudio = playdate.sound.fileplayer.new("assets/audio/game")
scene.levelAudio:setVolume(0.7)
scene.helloAudio = playdate.sound.fileplayer.new("assets/audio/hello")
@@ -68,7 +68,7 @@ function scene:start()
playdate.ui.crankIndicator:draw() -- not sure why this is not working
self.optionsMenu:addMenuItem("Main Menu", function() Noble.transition(Menu) end)
Noble.showFPS = true
Noble.showFPS = false
end
function scene:spawnBaleba()

View File

@@ -16,6 +16,11 @@ function scene:setValues()
self.menuYFrom = -50
self.menuY = 15
self.menuYTo = 240
scene.musicEnabled = Noble.Settings.get("music")
scene.levelAudio = playdate.sound.fileplayer.new("assets/audio/menu")
scene.levelAudio:setVolume(0.7)
end
function scene:init()
@@ -66,6 +71,10 @@ end
function scene:enter()
scene.super.enter(self)
self.sequence = Sequence.new():from(self.menuYFrom):to(self.menuY, 1.5, Ease.outBounce):start()
if scene.musicEnabled then
scene.levelAudio:play(0)
end
end
function scene:start()
@@ -97,12 +106,13 @@ end
function scene:exit()
scene.super.exit(self)
scene.levelAudio:stop()
self.sequence = Sequence.new():from(self.menuY):to(self.menuYTo, 0.5, Ease.inSine)
self.sequence:start();
self.sequence:start()
end
function scene:setupMenu(__menu)
__menu:addItem("Start", function() Noble.transition(DroneSelection, nil, Noble.Transition.DipToWhite) end)
__menu:addItem("Start", function() Noble.transition(DroneCardSelector, nil, Noble.Transition.DipToWhite) end)
__menu:addItem("Tutorial", function() return end)
__menu:addItem("Credits", function() return end)
__menu:select("Start")

View File

@@ -0,0 +1,13 @@
local pd <const> = playdate
local gfx <const> = Graphics
local fontSimple = Graphics.font.new('assets/fonts/peridot_7')
class('DroneCard').extends(gfx.sprite)
function DroneCard:init(x, y, drone)
self:setImage(gfx.image.new('assets/images/card_' .. drone.id .. '.png'))
self:setCenter(0, 0)
self:moveTo(x, y)
self:add()
end

View File

@@ -0,0 +1,22 @@
PageSprite = {}
class('PageSprite').extends(NobleSprite)
function PageSprite:init(x, y)
Baleba.super.init(self, "assets/sprites/pages", true)
self.animation:addState("1", 1, 1)
self.animation:addState("2", 2, 2)
self.animation:addState("3", 3, 3)
self.animation:addState("4", 4, 4)
self.animation:setState("1")
-- self:setCenter(0, 0)
self:setSize(64, 64)
self:moveTo(x, y)
self:add()
end
function PageSprite:set(page)
self.animation:setState(page .. "")
end