noble animations

This commit is contained in:
2024-06-02 20:25:27 +03:00
parent f19610e458
commit 3ca6427583
15 changed files with 218 additions and 192 deletions

View File

@@ -20,142 +20,117 @@ end
function scene:setValues()
scene.background = Graphics.image.new("assets/sprites/bg")
scene.telemLostSound = playdate.sound.fileplayer.new( "assets/audio/telemko" )
scene.telemLostSound = playdate.sound.fileplayer.new("assets/audio/telemko")
scene.telemLostSoundPlayed = false
scene.resultShowed = false
scene.musicEnabled = Noble.Settings.get("music")
scene.balebas = {}
scene.t = playdate.timer.new(10000)
scene.t.repeats = true
scene.tankTimer = playdate.timer.new(1000)
scene.fp = playdate.sound.fileplayer.new( "assets/audio/war" )
scene.fp:setVolume(0.7)
scene.hello = playdate.sound.fileplayer.new( "assets/audio/hello" )
scene.balebaSpawner = playdate.timer.new(10000)
scene.balebaSpawner.repeats = true
scene.levelAudio = playdate.sound.fileplayer.new("assets/audio/war")
scene.levelAudio:setVolume(0.7)
scene.helloAudio = playdate.sound.fileplayer.new("assets/audio/hello")
end
function scene:init()
scene.super.init(self)
scene:setValues()
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 = true
Noble.showFPS = true
end
function scene:spawnBaleba()
local baleba = Baleba(math.random(410, 900), math.random(10, 210), scene.player, true)
baleba:add()
local balebaCount = #scene.balebas
if balebaCount >= 6 then
return
end
return baleba
scene.balebas[balebaCount + 1] = Baleba(math.random(410, 900), math.random(10, 210), scene.player, true)
return scene.balebas[balebaCount + 1]
end
function scene:enter()
scene.super.enter(self)
scene.super.enter(self)
scene.player = Player(30, 30)
scene.player:add()
scene.ground = Ground(400, 225, scene.player)
scene.ground:add()
scene.player = Player(150, 100)
scene.ground = Ground(0, 225, scene.player)
scene.t.timerEndedCallback = function()
if #scene.balebas >= 6 then
return
end
local k = #scene.balebas+1
scene.balebaSpawner.timerEndedCallback = function()
--scene.balebas[k] = scene:spawnBaleba()
end
for i=1, 3 do
scene.balebas[i] = scene:spawnBaleba()
for i = 1, 3 do
scene:spawnBaleba()
end
local musicEnabled = Noble.Settings.get("music")
scene.hello:play(1)
if musicEnabled then
scene.fp:play(0)
scene.helloAudio:play(1)
if scene.musicEnabled then
scene.levelAudio:play(0)
end
scene.tankTimer.timerEndedCallback = function()
playdate.timer.performAfterDelay(1000, function()
scene.tank = Tank(550, 190, scene.player, scene.ground)
scene.tank:add()
end
scene:addSprite(scene.tank) -- Raw sprite
end)
end
function scene:update()
scene.super.update(self)
scene.super.update(self)
if scene.player == nil then
Noble.Text.draw("Telemetry Lost", 200, 110, Noble.Text.ALIGN_CENTER, false, font)
return
end
if scene.player.isDead() and not scene.telemLostSoundPlayed then
if scene.player.isDead() then
if scene.resultShowed ~= true then
Noble.Text.draw("Telemetry Lost", 200, 110, Noble.Text.ALIGN_CENTER, false, font)
end
else
Noble.Text.draw("Bat: " .. math.floor(scene.player.getBat() / 100), 10, 215, Noble.Text.ALIGN_LEFT, false, font)
end
if scene.player.isDead() and not scene.telemLostSoundPlayed then
scene.telemLostSound:play(1)
scene.telemLostSoundPlayed = true
screenShake(500, 5)
screenShake(1000, 5)
playdate.timer.performAfterDelay(4000, function()
scene.resultShowed = true
c = notify("Nice", function()
Noble.transition(Menu)
c:remove()
end)
c:moveTo(200, 120)
c:add()
end)
local et = playdate.timer.new(6000)
et.timerEndedCallback = function()
Noble.transition(Menu)
end
return
end
local bat = scene.player.getBat()
bat = math.floor(bat/100)
Noble.Text.draw("Bat: " .. bat, 10, 215, Noble.Text.ALIGN_LEFT, false, font)
end
function scene:destroyPlayer()
if scene.player ~= nil then
scene.player:remove()
scene.player = nil
end
end
function scene:exit()
scene.super.exit(self)
scene:destroyPlayer()
scene.ground:remove()
scene.ground = nil
scene.tank:remove()
scene.ground = nil
for i=1, #scene.balebas do
scene.balebas[i]:destroy()
scene.balebas[i] = nil
end
scene.telemLostSound:stop()
scene.telemLostSoundPlayed = false
scene.levelAudio:stop()
scene.balebaSpawner:remove()
scene.fp:stop()
scene.t:remove()
scene.t = nil
scene.tankTimer:remove()
scene.tankTimer = nil
Noble.showFPS = false
Noble.showFPS = false
end
function scene:finish()
scene.super.finish(self)
playdate.display.setScale(1)
end
scene.super.finish(self)
playdate.display.setScale(1)
end