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