rework + cool bomber

This commit is contained in:
2026-02-24 00:46:50 +01:00
parent 9eb426021e
commit 8a039adc05
46 changed files with 737 additions and 82 deletions

View File

@@ -6,22 +6,59 @@ local elapsedTime = 0
scene.inputHandler = {
AButtonDown = function()
if Drones[scene.menuIndex].locked == true then
local drone = Drones[scene.menuIndex]
-- If locked, try to buy
if drone.locked == true then
if drone.price <= 0 then return end
local money = Noble.GameData.get("money")
if money >= drone.price then
Noble.GameData.set("money", money - drone.price)
Noble.GameData.set("drone" .. drone.id, 1)
drone.locked = false
scene.menuConfirmSound:play(1)
scene.purchaseText = "-$" .. drone.price
scene.purchaseTimer = playdate.timer.new(1200, 0, 40, playdate.easingFunctions.outCubic)
screenShake(200, 3)
else
screenShake(300, 5)
scene.noMoneyTimer = playdate.timer.new(800, 0, 800, playdate.easingFunctions.linear)
end
return
end
CurrentMission.droneId = drone.id
scene.menuConfirmSound:play(1)
local mode = Drones[scene.menuIndex].mode
local mode = drone.mode
local soundTable = playdate.sound.playingSources()
for i=1, #soundTable do
soundTable[i]:stop()
end
if mode == Modes.bomber then
local stock = Noble.GameData.get("bomberStock")
if stock <= 0 then
return
end
Noble.GameData.set("bomberStock", stock - 1)
Noble.transition(BomberScene)
else
Noble.transition(Assemble)
end
end,
BButtonDown = function()
-- B on bomber drone: buy stock
local drone = Drones[scene.menuIndex]
if not drone.locked and drone.mode == Modes.bomber then
local money = Noble.GameData.get("money")
local stockPrice = drone.stockPrice or 50
if money >= stockPrice then
Noble.GameData.set("money", money - stockPrice)
Noble.GameData.set("bomberStock", Noble.GameData.get("bomberStock") + 1)
scene.menuConfirmSound:play(1)
scene.purchaseText = "-$" .. stockPrice
scene.purchaseY = 0
scene.purchaseTimer = playdate.timer.new(1200, 0, 40, playdate.easingFunctions.outCubic)
return
end
end
scene.menuBackSound:play(1)
Noble.transition(MapSelector)
end,
@@ -62,6 +99,10 @@ function scene:setValues()
scene.currentX = 0
scene.targetX = 0
scene.purchaseText = nil
scene.purchaseTimer = nil
scene.noMoneyTimer = nil
end
function scene:init()
@@ -78,6 +119,16 @@ end
function scene:enter()
scene.super.enter(self)
-- Update locked state from GameData
for i = 1, #Drones do
Drones[i].locked = (Noble.GameData.get("drone" .. i) == 0)
end
scene.menuIndex = 1
scene.currentX = 0
scene.targetX = 0
scene.cards = {}
for i = 1, #Drones do
scene.cards[i] = DroneCard(0, 0, Drones[i])
@@ -108,13 +159,54 @@ function scene:update()
scene.cards[i]:moveTo(x + scene.currentX, 25)
end
if Drones[scene.menuIndex].locked == false then
local drone = Drones[scene.menuIndex]
-- Money display
Noble.Text.draw("$" .. Noble.GameData.get("money"), 200, 5, Noble.Text.ALIGN_CENTER, false, fontMed)
if drone.locked and drone.price > 0 then
self.aKey:draw(315, 207 + dy)
Noble.Text.draw("Buy $" .. drone.price, 333, 210, Noble.Text.ALIGN_LEFT, false, fontMed)
elseif drone.locked then
Noble.Text.draw("Coming soon", 340, 210, Noble.Text.ALIGN_CENTER, false, fontMed)
elseif drone.mode == Modes.bomber then
local stock = Noble.GameData.get("bomberStock")
self.aKey:draw(315, 207 + dy)
Noble.Text.draw("Go (" .. stock .. "x)", 333, 210, Noble.Text.ALIGN_LEFT, false, fontMed)
else
self.aKey:draw(315, 207 + dy)
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)
-- B button: back or buy stock
if not drone.locked and drone.mode == Modes.bomber then
self.bKey:draw(15, 207 + dy)
Noble.Text.draw("Buy +1: $" .. (drone.stockPrice or 50), 33, 210, Noble.Text.ALIGN_LEFT, false, fontMed)
else
self.bKey:draw(15, 207 + dy)
Noble.Text.draw("Back", 33, 210, Noble.Text.ALIGN_LEFT, false, fontMed)
end
-- Not enough money warning
if scene.noMoneyTimer then
if scene.noMoneyTimer.value < 800 then
Noble.Text.draw("Not enough $!", 200, 190, Noble.Text.ALIGN_CENTER, false, fontMed)
else
scene.noMoneyTimer = nil
end
end
-- Purchase animation
if scene.purchaseText and scene.purchaseTimer then
local offset = scene.purchaseTimer.value
local alpha = 1.0 - (offset / 40)
if alpha > 0 then
Noble.Text.draw(scene.purchaseText, 200, 20 - offset, Noble.Text.ALIGN_CENTER, false, fontMed)
else
scene.purchaseText = nil
scene.purchaseTimer = nil
end
end
scene.paginator:moveTo(200, 207)
end