This commit is contained in:
2026-02-23 20:52:54 +01:00
parent fae2abf94e
commit 9eb426021e
32 changed files with 268 additions and 78 deletions

View File

@@ -159,11 +159,6 @@ This operation is crucial. Execute with precision. Command out.]]
-- self.dialogue:setPadding(4)
end
function round(number)
local formatted = string.format("%.2f", number)
return formatted
end
local elapsedTime = 0
function scene:update()
scene.super.update(self)

View File

@@ -10,7 +10,7 @@ scene.inputHandler = {
return
end
scene.menuConfirmSound:play(1)
mode = Drones[scene.menuIndex].mode
local mode = Drones[scene.menuIndex].mode
local soundTable = playdate.sound.playingSources()
for i=1, #soundTable do
soundTable[i]:stop()

View File

@@ -4,19 +4,6 @@ local scene = Game
local font = Graphics.font.new('assets/fonts/Mini Sans 2X')
local function screenShake(shakeTime, shakeMagnitude)
local shakeTimer = playdate.timer.new(shakeTime, shakeMagnitude, 0)
shakeTimer.updateCallback = function(timer)
local magnitude = math.floor(timer.value)
local shakeX = math.random(-magnitude, magnitude)
local shakeY = math.random(-magnitude, magnitude)
playdate.display.setOffset(shakeX, shakeY)
end
shakeTimer.timerEndedCallback = function()
playdate.display.setOffset(0, 0)
end
end
function scene:drawBackground()
local speed = 0.1
if scene.ground ~= nil then
@@ -66,8 +53,6 @@ end
function scene:start()
scene.super.start(self)
playdate.ui.crankIndicator:draw() -- not sure why this is not working
self.optionsMenu:addMenuItem("Main Menu", function() Noble.transition(Menu) end)
Noble.showFPS = false
end
@@ -103,14 +88,13 @@ function scene:enter()
end
end
function round(number)
local formatted = string.format("%.2f", number)
return formatted
end
function scene:update()
scene.super.update(self)
if playdate.isCrankDocked() then
playdate.ui.crankIndicator:draw()
end
if scene.player == nil then
return
end
@@ -169,6 +153,7 @@ function scene:exit()
if scene.tank ~= nil then
scene.tank:remove()
end
scene.helloAudio:stop()
scene.telemLostSound:stop()
scene.levelAudio:stop()
scene.balebaSpawner:remove()

View File

@@ -42,6 +42,7 @@ end
function scene:update()
scene.super.update(self)
if not scene.cards then return end
elapsedTime = elapsedTime + 1 / playdate.display.getRefreshRate()
local dy = 2 * math.sin(20 * elapsedTime)

View File

@@ -110,7 +110,7 @@ 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

View File

@@ -11,6 +11,11 @@ function scene:init()
self.bgY = 0
self.scrollSpeed = 0.6
scene.dropSound = playdate.sound.fileplayer.new("assets/audio/drop1")
scene.themeSound = playdate.sound.fileplayer.new("assets/audio/bomberTheme")
scene.themeSound:setVolume(0.5)
scene.themeSound:play()
scene.progressBar = ProgressBar(50, 210, 50, 5)
scene.progressBar:set(0)
scene.progressBar:setVisible(false)
@@ -19,9 +24,22 @@ function scene:init()
scene.grenadeCooldownTimer = nil
scene.grenadeCooldownDuration = 100
scene.progressBarMax = 100
scene.autoReload = false
scene.reloadProgress = 0
scene.crankSensitivity = 0.2
scene.availableGrenades = 8
scene.enemies = {}
scene.enemySpawnTimer = nil
scene.enemySpawnInterval = 1000
scene.maxEnemies = 5
scene.nextEnemyIndex = 1
scene.minSpawnDelay = 500
scene.maxSpawnDelay = 3500
BomberScene.instance = self
end
@@ -63,15 +81,21 @@ scene.inputHandler = {
scene.progressBar:set(0)
scene.progressBar:setVisible(true)
scene.availableGrenades = scene.availableGrenades - 1
scene.dropSound:play()
scene.grenadeCooldownTimer = playdate.timer.new(scene.grenadeCooldownDuration, function()
scene.grenadeCooldown = false
scene.progressBar:setVisible(false)
end)
scene.grenadeCooldownTimer.updateCallback = function(timer)
local percentage = (scene.grenadeCooldownDuration - timer.timeLeft) / scene.grenadeCooldownDuration * scene.progressBarMax
scene.progressBar:set(percentage)
if scene.autoReload then
scene.grenadeCooldownTimer = playdate.timer.new(scene.grenadeCooldownDuration, function()
scene.grenadeCooldown = false
scene.progressBar:setVisible(false)
end)
scene.grenadeCooldownTimer.updateCallback = function(timer)
local percentage = (scene.grenadeCooldownDuration - timer.timeLeft) / scene.grenadeCooldownDuration * scene.progressBarMax
scene.progressBar:set(percentage)
end
else
scene.reloadProgress = 0
end
end
end
@@ -81,6 +105,9 @@ function scene:enter()
scene.super.enter(self)
Noble.Input.setHandler(scene.inputHandler)
scene.crosshair = MovableCrosshair(100, 100)
scene:scheduleNextEnemySpawn()
NoiseAnimation(200, 120)
end
function scene:start()
@@ -91,23 +118,81 @@ end
function scene:update()
scene.super.update(self)
if scene.grenadeCooldown and not scene.autoReload and not playdate.isCrankDocked() then
local change = playdate.getCrankChange()
if change > 0 or change < 0 then
scene.reloadProgress = scene.reloadProgress + (change * scene.crankSensitivity)
if scene.reloadProgress > scene.progressBarMax then
scene.reloadProgress = scene.progressBarMax
scene.grenadeCooldown = false
scene.progressBar:setVisible(false)
end
scene.progressBar:set(scene.reloadProgress)
end
end
Noble.Text.draw(scene.availableGrenades .. "x", 10, 210, Noble.Text.ALIGN_LEFT, false, font)
if scene.availableGrenades <= 0 then
Noble.Text.draw("No grenades left", 200, 110, Noble.Text.ALIGN_CENTER, false, font)
scene.crosshair:setVisible(false)
end
if playdate.isCrankDocked() then
scene.progressBar:setVisible(false)
elseif playdate.isCrankDocked() then
Noble.Text.draw("Crank it to reload!", 200, 110, Noble.Text.ALIGN_CENTER, false, font)
playdate.ui.crankIndicator:draw()
end
end
-- TODO: to reset grenades spin crank
-- TODO: random spawn of enemies
function scene:spawnEnemies()
local activeEnemies = 0
for i = 1, #scene.enemies do
if scene.enemies[i] and not scene.enemies[i].removed then
activeEnemies = activeEnemies + 1
end
end
if activeEnemies < self.maxEnemies then
scene.enemies[scene.nextEnemyIndex] = Enemy(math.random(30, 370), -20)
scene.nextEnemyIndex = scene.nextEnemyIndex + 1
end
scene:scheduleNextEnemySpawn()
end
function scene:scheduleNextEnemySpawn()
local delay = math.random(scene.minSpawnDelay, scene.maxSpawnDelay)
scene.enemySpawnTimer = playdate.timer.new(delay, function()
scene:spawnEnemies()
end)
end
function scene:finish()
scene.themeSound:stop()
scene.enemySpawnTimer:remove()
for i = 1, #scene.enemies do
if scene.enemies[i] then
scene.enemies[i]:remove()
end
end
scene.enemies = {}
if scene.progressBar then
scene.progressBar:remove()
end
scene.progressBar = nil
if scene.grenadeCooldownTimer then
scene.grenadeCooldownTimer:remove()
end
scene.grenadeCooldownTimer = nil
scene.crosshair:remove()
scene.crosshair = nil
BomberScene.instance = nil
end
-- TODO: random spawn some decorations
-- TODO: add some music
-- TODO: add some sound effects
-- TODO: add clouds or smoke
-- TODO: random disactivate granades