alpha 0.1
This commit is contained in:
@@ -3,23 +3,12 @@ class("Assemble").extends(BaseScene)
|
||||
local scene = Assemble
|
||||
|
||||
local font = Graphics.font.new('assets/fonts/Mini Sans 2X')
|
||||
local fontMed = Graphics.font.new('assets/fonts/onyx_9')
|
||||
|
||||
local allButtons = { "A", "B", "DOWN", "LEFT", "RIGHT", "UP" }
|
||||
|
||||
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:popCode(button)
|
||||
scene.menuConfirmSound:stop()
|
||||
if scene.tickTimer.paused then
|
||||
scene.droneParts = scene:loadDrone(1, #scene.code)
|
||||
scene.tickTimer:start()
|
||||
@@ -30,12 +19,14 @@ function scene:popCode(button)
|
||||
scene.tickTimer:reset()
|
||||
scene.dronePartIndex = scene.dronePartIndex + 1
|
||||
|
||||
local particle = ParticlePoly(200, 190 + 8)
|
||||
local particle = ParticlePoly(200, 185)
|
||||
particle:setThickness(2)
|
||||
particle:setSize(1, 2)
|
||||
particle:setSpeed(1, 3)
|
||||
particle:setColour(Graphics.kColorXOR)
|
||||
particle:add(5)
|
||||
scene.dY = 5
|
||||
scene.menuConfirmSound:play(1)
|
||||
else
|
||||
self.buttonTimeout = self.buttonTimeout - 5
|
||||
scene.code[1] = scene:randomButton()
|
||||
@@ -62,6 +53,7 @@ function scene:drawBackground()
|
||||
end
|
||||
|
||||
local screwDriver = Graphics.image.new('assets/sprites/assemble/sd.png')
|
||||
local solder = Graphics.image.new('assets/images/solder.png')
|
||||
|
||||
function scene:loadButtons()
|
||||
local buttons = {}
|
||||
@@ -90,22 +82,30 @@ function scene:setValues()
|
||||
table.insert(scene.code, scene:randomButton())
|
||||
end
|
||||
|
||||
scene.difficulty = Noble.Settings.get("difficulty")
|
||||
|
||||
scene.buttons = scene:loadButtons()
|
||||
scene.droneParts = {}
|
||||
scene.dronePartIndex = 0
|
||||
scene.dY = 5
|
||||
|
||||
scene.buttonTimeout = 100
|
||||
|
||||
scene.timeToClick = DifficultySettings[scene.difficulty].assebleTime
|
||||
|
||||
scene.menuConfirmSound = playdate.sound.fileplayer.new("assets/audio/confirm")
|
||||
self.aKey = Graphics.image.new("assets/sprites/buttons/A")
|
||||
end
|
||||
|
||||
function scene:init()
|
||||
scene.super.init(self)
|
||||
scene:setValues()
|
||||
|
||||
scene.buttonTimeout = 100
|
||||
|
||||
scene.progressBar = ProgressBar(200, 170, 50, 5)
|
||||
scene.progressBar = ProgressBar(200, 175, 50, 5)
|
||||
scene.progressBar:set(self.buttonTimeout)
|
||||
scene.progressBar:setVisible(false)
|
||||
|
||||
scene.tickTimer = playdate.timer.new(2500, self.buttonTimeout, 0, playdate.easingFunctions.linear)
|
||||
scene.tickTimer = playdate.timer.new(scene.timeToClick, self.buttonTimeout, 0, playdate.easingFunctions.linear)
|
||||
scene.tickTimer.updateCallback = function(timer)
|
||||
scene.buttonTimeout = timer.value
|
||||
scene.progressBar:set(scene.buttonTimeout)
|
||||
@@ -132,14 +132,40 @@ function round(number)
|
||||
return formatted
|
||||
end
|
||||
|
||||
local elapsedTime = 0
|
||||
function scene:update()
|
||||
scene.super.update(self)
|
||||
elapsedTime = elapsedTime + 1 / playdate.display.getRefreshRate()
|
||||
|
||||
local sddy = 4 * math.sin(10 * elapsedTime)
|
||||
local sdy = 4 * math.sin(7 * elapsedTime)
|
||||
local sddx = 2 * math.cos(5 * elapsedTime)
|
||||
|
||||
if scene.tickTimer.paused then
|
||||
Noble.Text.draw("Assemble the drone!", 200, 110, Noble.Text.ALIGN_CENTER, false, font)
|
||||
end
|
||||
|
||||
if #scene.code == 0 then
|
||||
Noble.Text.draw("WIN!", 200, 110, Noble.Text.ALIGN_CENTER, false, font)
|
||||
local dy = 1 * math.sin(10 * elapsedTime)
|
||||
|
||||
Noble.Transition.setDefaultProperties(Noble.Transition.SpotlightMask, {
|
||||
x = 325,
|
||||
y = 95,
|
||||
xEnd = 96,
|
||||
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()
|
||||
self.tickTimer:remove()
|
||||
scene.inputHandler = {}
|
||||
return
|
||||
end
|
||||
|
||||
@@ -148,18 +174,23 @@ function scene:update()
|
||||
self.progressBar:remove()
|
||||
self.tickTimer:remove()
|
||||
screenShake(100, 5)
|
||||
scene.inputHandler = {}
|
||||
Noble.Input.setEnabled(false)
|
||||
return
|
||||
end
|
||||
|
||||
screwDriver:draw(300, 100)
|
||||
screwDriver:draw(300 + sddx, 100 + sddy)
|
||||
solder:draw(0, 100 + sdy)
|
||||
|
||||
if scene.droneParts ~= nil and scene.dronePartIndex ~= nil and scene.dronePartIndex > 0 and #scene.droneParts > 0 then
|
||||
scene.droneParts[scene.dronePartIndex]:draw(100, 20)
|
||||
end
|
||||
|
||||
Graphics.drawLine(200, 175, 200, 185)
|
||||
Graphics.drawLine(200, 212, 200, 222)
|
||||
Graphics.drawLine(180, 185, 192, 185)
|
||||
Graphics.drawLine(208, 185, 220, 185)
|
||||
|
||||
if scene.dY > 0 then
|
||||
scene.dY = self.dY - 0.5
|
||||
end
|
||||
|
||||
for i = 1, #scene.code do
|
||||
local button = scene.buttons[scene.code[i]]
|
||||
@@ -171,7 +202,9 @@ function scene:update()
|
||||
local t = (i - 1) / (#scene.code - first)
|
||||
local opaque = playdate.math.lerp(1, 0.3, t) --TODO: not the best solution
|
||||
|
||||
button:drawFaded(200 + ((i - 1) * 16) - 8, 190, opaque, playdate.graphics.image.kDitherTypeBayer2x2)
|
||||
local y = 185 + ((i - 1) * 16) - 8 + scene.dY
|
||||
|
||||
button:drawFaded(192, y, opaque, playdate.graphics.image.kDitherTypeBayer2x2)
|
||||
end
|
||||
end
|
||||
|
||||
|
117
source/scenes/DroneSelection.lua
Normal file
117
source/scenes/DroneSelection.lua
Normal file
@@ -0,0 +1,117 @@
|
||||
DroneSelection = {}
|
||||
class("DroneSelection").extends(BaseScene)
|
||||
local scene = DroneSelection
|
||||
|
||||
local fontSimple = Graphics.font.new('assets/fonts/peridot_7')
|
||||
local fontMed = Graphics.font.new('assets/fonts/onyx_9')
|
||||
local fontBig = Graphics.font.new('assets/fonts/diamond_20')
|
||||
|
||||
scene.inputHandler = {
|
||||
AButtonDown = function()
|
||||
scene.menuConfirmSound:play(1)
|
||||
Noble.transition(Assemble)
|
||||
end,
|
||||
BButtonDown = function() end,
|
||||
downButtonDown = function()
|
||||
scene.menuSelSound:play(1)
|
||||
if scene.menuIndex < 4 then
|
||||
scene.menuIndex = scene.menuIndex + 1
|
||||
else
|
||||
scene.menuIndex = 1
|
||||
end
|
||||
end,
|
||||
leftButtonDown = function() end,
|
||||
rightButtonDown = function() end,
|
||||
upButtonDown = function()
|
||||
scene.menuSelSound:play(1)
|
||||
if scene.menuIndex > 1 then
|
||||
scene.menuIndex = scene.menuIndex - 1
|
||||
else
|
||||
scene.menuIndex = 4
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
function scene:setValues()
|
||||
self.dronesPreview = {}
|
||||
self.background = Graphics.image.new("assets/sprites/selectionBg1")
|
||||
self.dronesPreview[1] = Graphics.image.new("assets/sprites/assemble/1/8.png")
|
||||
|
||||
self.aKey = Graphics.image.new("assets/sprites/buttons/A")
|
||||
|
||||
scene.menuSelSound = playdate.sound.fileplayer.new("assets/audio/menu_select")
|
||||
scene.menuSelSound:setVolume(0.5)
|
||||
|
||||
scene.menuConfirmSound = playdate.sound.fileplayer.new("assets/audio/confirm")
|
||||
-- scene.menuConfirmSound:setVolume(0.5)
|
||||
|
||||
scene.unknownDrone = Graphics.image.new("assets/images/unk.png")
|
||||
|
||||
self.menuIndex = 1
|
||||
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.selectionAnim = Selection(23, 54)
|
||||
end
|
||||
|
||||
local elapsedTime = 0
|
||||
function scene:update()
|
||||
scene.super.update(self)
|
||||
Noble.Text.draw("Select Drone", 200, 10, Noble.Text.ALIGN_CENTER, false, fontMed)
|
||||
scene.selectionAnim:moveTo(23, 54 + (self.menuIndex - 1) * 46)
|
||||
|
||||
elapsedTime = elapsedTime + 1 / playdate.display.getRefreshRate()
|
||||
local dy = 1 * math.sin(10 * elapsedTime)
|
||||
|
||||
local offset = 42
|
||||
|
||||
for i = 1, #Drones do
|
||||
if Drones[i].locked == true then
|
||||
Noble.Text.draw("UNAVAILABLE", 47, offset + 7, Noble.Text.ALIGN_LEFT, false, fontMed)
|
||||
Noble.Text.draw("?", 16, offset + 4, Noble.Text.ALIGN_LEFT, false, fontBig)
|
||||
else
|
||||
Drones[i].preview:draw(6, offset)
|
||||
|
||||
Noble.Text.draw(Drones[i].name, 49, offset - 3, Noble.Text.ALIGN_LEFT, false, fontMed)
|
||||
Noble.Text.draw("Price:", 49, offset + 15, Noble.Text.ALIGN_LEFT, false, fontSimple)
|
||||
Noble.Text.draw("$" .. Drones[i].price, 103, offset + 15, Noble.Text.ALIGN_LEFT, false, fontSimple)
|
||||
end
|
||||
offset = offset + 46
|
||||
end
|
||||
|
||||
if Drones[self.menuIndex].locked == false then
|
||||
self.aKey:draw(330, 170 + dy) -- A key
|
||||
Noble.Text.draw("Assemble", 348, 175, Noble.Text.ALIGN_LEFT, false, fontSimple) -- Assemble text
|
||||
|
||||
Graphics.drawTextInRect(Drones[self.menuIndex].description, 135, 200, 255, 100, nil, nil, nil, fontSimple) -- Description
|
||||
Drones[self.menuIndex].full:draw(160, 35) -- Drone preview (full size)
|
||||
else
|
||||
Graphics.drawTextInRect("Unavailable right now", 135, 200, 255, 100, nil, nil, nil, fontSimple)
|
||||
scene.unknownDrone:draw(184, 35)
|
||||
end
|
||||
end
|
||||
|
||||
function scene:exit()
|
||||
scene.super.exit(self)
|
||||
|
||||
Noble.showFPS = false
|
||||
end
|
||||
|
||||
function scene:finish()
|
||||
scene.super.finish(self)
|
||||
playdate.display.setScale(1)
|
||||
end
|
@@ -78,7 +78,7 @@ function scene:spawnBaleba()
|
||||
return
|
||||
end
|
||||
|
||||
--scene.balebas[balebaCount + 1] = Baleba(math.random(410, 900), math.random(10, 210), scene.player, true)
|
||||
scene.balebas[balebaCount + 1] = Baleba(math.random(410, 900), math.random(10, 210), scene.player, true)
|
||||
end
|
||||
|
||||
function scene:enter()
|
||||
@@ -96,9 +96,9 @@ function scene:enter()
|
||||
scene:spawnBaleba()
|
||||
end
|
||||
|
||||
--scene.helloAudio:play(1)
|
||||
scene.helloAudio:play(1)
|
||||
if scene.musicEnabled then
|
||||
--scene.levelAudio:play(0)
|
||||
scene.levelAudio:play(0)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -164,7 +164,9 @@ end
|
||||
function scene:exit()
|
||||
scene.super.exit(self)
|
||||
|
||||
scene.tank:remove()
|
||||
if scene.tank ~= nil then
|
||||
scene.tank:remove()
|
||||
end
|
||||
scene.telemLostSound:stop()
|
||||
scene.levelAudio:stop()
|
||||
scene.balebaSpawner:remove()
|
||||
|
@@ -2,10 +2,8 @@ Menu = {}
|
||||
class("Menu").extends(BaseScene)
|
||||
local scene = Menu
|
||||
|
||||
|
||||
|
||||
function scene:setValues()
|
||||
self.background = Graphics.image.new("assets/images/background2")
|
||||
self.background = Graphics.image.new("assets/images/menuBg")
|
||||
|
||||
self.color1 = Graphics.kColorBlack
|
||||
self.color2 = Graphics.kColorWhite
|
||||
@@ -26,9 +24,12 @@ function scene:init()
|
||||
local menuSelSound = playdate.sound.fileplayer.new("assets/audio/menu_select")
|
||||
menuSelSound:setVolume(0.5)
|
||||
|
||||
local menuConfirmSound = playdate.sound.fileplayer.new("assets/audio/confirm")
|
||||
-- menuConfirmSound:setVolume(0.5)
|
||||
|
||||
self:setValues()
|
||||
|
||||
self.menu = Noble.Menu.new(false, Noble.Text.ALIGN_CENTER, false, self.color2, 4,6,0, Noble.Text.FONT_SMALL)
|
||||
self.menu = Noble.Menu.new(false, Noble.Text.ALIGN_CENTER, false, self.color2, 4, 6, 0, Noble.Text.FONT_SMALL)
|
||||
|
||||
self:setupMenu(self.menu)
|
||||
|
||||
@@ -56,10 +57,10 @@ function scene:init()
|
||||
end
|
||||
end,
|
||||
AButtonDown = function()
|
||||
menuConfirmSound:play(1)
|
||||
self.menu:click()
|
||||
end
|
||||
}
|
||||
|
||||
end
|
||||
|
||||
function scene:enter()
|
||||
@@ -86,13 +87,12 @@ function scene:update()
|
||||
|
||||
Graphics.setColor(self.color1)
|
||||
Graphics.setDitherPattern(0.2, Graphics.image.kDitherTypeScreen)
|
||||
Graphics.fillRoundRect(200-38, 160-8, 75, 60, 15)
|
||||
Graphics.fillRoundRect(200 - 38, 160 - 8, 75, 60, 15)
|
||||
self.menu:draw(200, 160)
|
||||
|
||||
logo_image:draw(120, 55)
|
||||
-- logo_image:draw(120, 55)
|
||||
|
||||
Graphics.setColor(Graphics.kColorBlack)
|
||||
|
||||
end
|
||||
|
||||
function scene:exit()
|
||||
@@ -102,8 +102,8 @@ function scene:exit()
|
||||
end
|
||||
|
||||
function scene:setupMenu(__menu)
|
||||
__menu:addItem("Start", function() Noble.transition(Game, nil, Noble.Transition.DipToWhite) end)
|
||||
__menu:addItem("Tutorial", function() return end)
|
||||
__menu:addItem("Credits", function() return end)
|
||||
__menu:addItem("Start", function() Noble.transition(DroneSelection, nil, Noble.Transition.DipToWhite) end)
|
||||
__menu:addItem("Tutorial", function() return end)
|
||||
__menu:addItem("Credits", function() return end)
|
||||
__menu:select("Start")
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user