feat: add dialogue

This commit is contained in:
2024-06-14 20:33:09 +03:00
parent 60002df6e1
commit 1349e92491
21 changed files with 839 additions and 42 deletions

View File

@@ -88,7 +88,7 @@ end
function scene:setValues()
scene.code = {}
for i = 1, 9 do
for i = 1, 1 do
table.insert(scene.code, scene:randomButton())
end
@@ -104,7 +104,6 @@ function scene:setValues()
scene.timeToClick = DifficultySettings[scene.difficulty].assebleTime
scene.menuConfirmSound = playdate.sound.fileplayer.new("assets/audio/confirm")
self.aKey = Graphics.image.new("assets/sprites/buttons/A")
scene.musicEnabled = Noble.Settings.get("music")
@@ -148,6 +147,17 @@ function scene:enter()
if scene.musicEnabled then
scene.levelAudio:play(0)
end
local text =
[[The drone is assembled and operational. We are ready for the mission.
An enemy tank is confirmed in the field. It threatens our advance.
Your task: eliminate the target. Clear the path for our assault units.
This operation is crucial. Execute with precision. Command out.]]
self.dialogue = pdDialogueBox(text, 390, 46)
-- self.dialogue:setPadding(4)
end
function round(number)
@@ -158,35 +168,60 @@ 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)
elapsedTime = elapsedTime + 1 / playdate.display.getRefreshRate()
local sddy = 0
local sdy = 0
local sddx = 0
if #scene.code == 0 then
if self.dialogue.enabled ~= true then
Noble.Input.setHandler(self.dialogue:getInputHandlers())
function self.dialogue:onClose()
Noble.Transition.setDefaultProperties(Noble.Transition.SpotlightMask, {
x = 325,
y = 95,
xEnd = 96,
yEnd = 100,
invert = false
})
scene.menuConfirmSound:play(1)
Noble.transition(Game, nil, Noble.Transition.SpotlightMask)
end
self.dialogue:enable()
return
else
scene.droneParts[#scene.droneParts]:draw(100, 20)
local dy = 1 * math.sin(10 * elapsedTime)
self.dialogue:update()
self.dialogue:draw(5, 186 + dy)
end
self.progressBar:remove()
self.tickTimer:remove()
end
if #scene.code ~= 0 then -- TODO: this is a hack. no, it's not. it's a SHIT. Why i am do this? What i do with my life?
sddy = 4 * math.sin(10 * elapsedTime)
sdy = 4 * math.sin(7 * elapsedTime)
sddx = 2 * math.cos(5 * elapsedTime)
end
screwDriver:draw(300 + sddx, 100 + sddy)
solder:draw(0, 100 + sdy)
if #scene.code == 0 then
return
end
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
local dy = 1 * math.sin(10 * elapsedTime)
Noble.Transition.setDefaultProperties(Noble.Transition.SpotlightMask, {
x = 325,
y = 95,
xEnd = 96,
yEnd = 100,
invert = false
})
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()
return
end
if scene.buttonTimeout <= 0 then
Noble.Text.draw("LOSE!", 200, 110, Noble.Text.ALIGN_CENTER, false, font)
Noble.Text.draw("Fuck!", 200, 110, Noble.Text.ALIGN_CENTER, false, font)
self.progressBar:remove()
self.tickTimer:remove()
screenShake(100, 5)
@@ -194,9 +229,6 @@ function scene:update()
return
end
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

View File

@@ -7,26 +7,25 @@ class("BaseScene").extends(NobleScene)
function BaseScene:init()
BaseScene.super.init(self)
pd.resetElapsedTime() -- Reset time so each scene starts at 0
self.optionsMenu = pd.getSystemMenu() -- Store this so we have access to it in all scenes
pd.resetElapsedTime() -- Reset time so each scene starts at 0
self.optionsMenu = pd.getSystemMenu() -- Store this so we have access to it in all scenes
end
function BaseScene:update()
BaseScene.super.update(self)
Particles:update() -- Update our particle library
Particles:update()
end
function BaseScene:exit()
BaseScene.super.exit(self)
self.optionsMenu:removeAllMenuItems() -- Remove all custom menu items and reset menu image
self.optionsMenu:removeAllMenuItems() -- Remove all custom menu items and reset menu image
pd.setMenuImage(nil)
end
function BaseScene:drawBackground()
BaseScene.super.drawBackground(self)
BaseScene.super.drawBackground(self)
if self.background ~= nil then -- Helper so you can set a scene's background to an image
if self.background ~= nil then -- Helper so you can set a scene's background to an image
self.background:draw(0, 0)
end
end
end

View File

@@ -129,6 +129,7 @@ function scene:update()
end
if scene.player.isDead() then
scene.ground:setMoveSpeed(0)
if scene.resultShowed ~= true then
Noble.Text.draw("Telemetry Lost", 200, 110, Noble.Text.ALIGN_CENTER, false, font)
end