bomber imp
This commit is contained in:
@@ -143,10 +143,6 @@ 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)
|
||||
|
@@ -10,7 +10,16 @@ scene.inputHandler = {
|
||||
return
|
||||
end
|
||||
scene.menuConfirmSound:play(1)
|
||||
Noble.transition(Assemble)
|
||||
mode = Drones[scene.menuIndex].mode
|
||||
local soundTable = playdate.sound.playingSources()
|
||||
for i=1, #soundTable do
|
||||
soundTable[i]:stop()
|
||||
end
|
||||
if mode == Modes.bomber then
|
||||
Noble.transition(BomberScene)
|
||||
else
|
||||
Noble.transition(Assemble)
|
||||
end
|
||||
end,
|
||||
BButtonDown = function()
|
||||
scene.menuBackSound:play(1)
|
||||
|
@@ -55,7 +55,7 @@ function scene:update()
|
||||
|
||||
local x = 0
|
||||
for i = 1, #scene.cards do
|
||||
x = 0 + (339 + 16) * (i - 1)
|
||||
x = 400 * (i - 1)
|
||||
scene.cards[i]:moveTo(x + scene.currentX, 0)
|
||||
end
|
||||
|
||||
@@ -107,7 +107,7 @@ scene.inputHandler = {
|
||||
return
|
||||
end
|
||||
scene.menuSelSound:play(1)
|
||||
scene.targetX = scene.targetX + 355
|
||||
scene.targetX = scene.targetX + 400
|
||||
scene.menuIndex = scene.menuIndex - 1
|
||||
end,
|
||||
rightButtonDown = function()
|
||||
@@ -115,7 +115,7 @@ scene.inputHandler = {
|
||||
return
|
||||
end
|
||||
scene.menuSelSound:play(1)
|
||||
scene.targetX = scene.targetX - 355
|
||||
scene.targetX = scene.targetX - 400
|
||||
scene.menuIndex = scene.menuIndex + 1
|
||||
end,
|
||||
upButtonDown = function()
|
||||
|
@@ -24,6 +24,10 @@ function scene:setValues()
|
||||
end
|
||||
|
||||
function scene:init()
|
||||
local soundTable = playdate.sound.playingSources()
|
||||
for i=1, #soundTable do
|
||||
soundTable[i]:stop()
|
||||
end
|
||||
scene.super.init(self)
|
||||
|
||||
local menuSelSound = playdate.sound.fileplayer.new("assets/audio/menu_select")
|
||||
|
@@ -2,9 +2,38 @@ BomberScene = {}
|
||||
class("BomberScene").extends(BaseScene)
|
||||
local scene = BomberScene
|
||||
|
||||
local font = Graphics.font.new('assets/fonts/Mini Sans 2X')
|
||||
|
||||
function scene:init()
|
||||
scene.super.init(self)
|
||||
scene.granade = nil
|
||||
|
||||
self.bg = Graphics.image.new("assets/sprites/bg2")
|
||||
self.bgY = 0
|
||||
self.scrollSpeed = 0.6
|
||||
|
||||
scene.progressBar = ProgressBar(50, 210, 50, 5)
|
||||
scene.progressBar:set(0)
|
||||
scene.progressBar:setVisible(false)
|
||||
|
||||
scene.grenadeCooldown = false
|
||||
scene.grenadeCooldownTimer = nil
|
||||
scene.grenadeCooldownDuration = 100
|
||||
scene.progressBarMax = 100
|
||||
|
||||
scene.availableGrenades = 8
|
||||
|
||||
BomberScene.instance = self
|
||||
end
|
||||
|
||||
function scene:drawBackground()
|
||||
self.bgY = self.bgY + self.scrollSpeed
|
||||
|
||||
if self.bgY >= 720 then
|
||||
self.bgY = 0
|
||||
end
|
||||
|
||||
self.bg:draw(0, self.bgY - 720)
|
||||
self.bg:draw(0, self.bgY)
|
||||
end
|
||||
|
||||
|
||||
@@ -22,8 +51,29 @@ scene.inputHandler = {
|
||||
scene.crosshair:moveRight()
|
||||
end,
|
||||
AButtonDown = function()
|
||||
if scene.availableGrenades <= 0 then
|
||||
return
|
||||
end
|
||||
|
||||
print("AButtonDown")
|
||||
scene.granade = Granade(scene.crosshair.x, scene.crosshair.y)
|
||||
if not scene.grenadeCooldown then
|
||||
Granade(scene.crosshair.x, scene.crosshair.y)
|
||||
scene.grenadeCooldown = true
|
||||
|
||||
scene.progressBar:set(0)
|
||||
scene.progressBar:setVisible(true)
|
||||
scene.availableGrenades = scene.availableGrenades - 1
|
||||
|
||||
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
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
@@ -35,13 +85,29 @@ end
|
||||
|
||||
function scene:start()
|
||||
scene.super.start(self)
|
||||
self.optionsMenu:addMenuItem("Main Menu", function() Noble.transition(Menu) end)
|
||||
Noble.showFPS = true
|
||||
end
|
||||
|
||||
function scene:update()
|
||||
scene.super.update(self)
|
||||
-- scene.crosshair:update()
|
||||
|
||||
-- if scene.granade then
|
||||
-- scene.granade:update()
|
||||
-- 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
|
||||
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
|
||||
-- TODO: random spawn some decorations
|
||||
-- TODO: add some music
|
||||
-- TODO: add some sound effects
|
||||
-- TODO: add clouds or smoke
|
||||
-- TODO: random disactivate granades
|
Reference in New Issue
Block a user