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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user