Skip to content

Commit

Permalink
Use up and down to move the glasses too
Browse files Browse the repository at this point in the history
  • Loading branch information
bdougherty committed May 13, 2022
1 parent bde36b1 commit f1ba276
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions source/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "CoreLibs/crank"

local gfx <const> = playdate.graphics

local maxGlasses = 68
local maxGlassesY = 68
local reminderDelay = 3000
local crankIndicatorStarted = false
local hasMovedCrank = false
Expand Down Expand Up @@ -42,15 +42,29 @@ function playdate.cranked()
hasMovedCrank = true
end

function playdate.upButtonDown()
hasMovedCrank = true
end

function playdate.downButtonDown()
hasMovedCrank = true
end

function playdate.update()
local ticks = playdate.getCrankTicks(12)
local glassesDeltaY = 0

if ticks ~= 0 then
local newY = math.max(glasses.y + ticks * 2, 0 - glasses.height)
glasses:moveTo(glasses.x, math.min(newY, maxGlasses))
if playdate.buttonIsPressed(playdate.kButtonUp) then
glassesDeltaY = -2
elseif playdate.buttonIsPressed(playdate.kButtonDown) then
glassesDeltaY = 2
elseif ticks ~= 0 then
glassesDeltaY = ticks * 2
end

if glasses.y >= maxGlasses then
local glassesNewY = math.max(glasses.y + glassesDeltaY, 0 - glasses.height)
glasses:moveTo(glasses.x, math.min(glassesNewY, maxGlassesY))
if glasses.y >= maxGlassesY then
dealWithIt:setVisible(true)
else
dealWithIt:setVisible(false)
Expand Down

0 comments on commit f1ba276

Please sign in to comment.