84 lines
No EOL
2.9 KiB
Lua
84 lines
No EOL
2.9 KiB
Lua
paused = false
|
|
playbackRate = 1.0
|
|
local timeRate = true
|
|
songTitle = "AAA"
|
|
local number = math.random(1000,9999)
|
|
|
|
local imgDither = playdate.graphics.image.new("gfx/dither")
|
|
local imgCover = playdate.graphics.image.new("gfx/cover1bit")
|
|
assert(imgDither)
|
|
assert(imgCover)
|
|
|
|
function updateBox()
|
|
playdate.graphics.clear()
|
|
|
|
processStars(-10,-10)
|
|
|
|
local change, aChange = playdate.getCrankChange()
|
|
|
|
if paused then
|
|
if change<0 then change = 0 end
|
|
song:setRate(change*0.03)
|
|
if not playdate.isCrankDocked() then
|
|
playdate.graphics.drawText(math.floor((change*0.03)*100).."%", 200 - playdate.graphics.getTextSize(math.floor((change*0.03)*100).."%")/ 2,210)
|
|
end
|
|
else
|
|
playbackRate += change*0.0005
|
|
if playbackRate < 0.2 then playbackRate = 0.2 elseif playbackRate > 3 then playbackRate = 3 end
|
|
if not playdate.isCrankDocked() or math.floor(playbackRate*100) ~= 100 then
|
|
playdate.graphics.drawText(math.floor(playbackRate * 100).."%", 200 - playdate.graphics.getTextSize(math.floor(playbackRate * 100).."%")/ 2,210)
|
|
end
|
|
song:setRate(playbackRate)
|
|
end
|
|
if playdate.buttonJustPressed(playdate.kButtonA) then
|
|
if paused == true then
|
|
paused = false
|
|
else
|
|
paused = true
|
|
end
|
|
playbackRate = 1.0
|
|
end
|
|
|
|
if paused then playdate.graphics.setPattern(imgDither) end
|
|
playdate.graphics.setLineWidth(10)
|
|
|
|
playdate.graphics.drawLine(0,235,(song:getOffset()/song:getLength())*400,235)
|
|
|
|
playdate.graphics.setColor(playdate.graphics.kColorWhite)
|
|
playdate.graphics.setLineWidth(2)
|
|
|
|
playdate.graphics.drawLine(0,19,400,19)
|
|
|
|
local time = playdate.getTime()
|
|
if timeRate == true then
|
|
local prefix = " AM"
|
|
if time.hour > 12 then prefix = " PM" end
|
|
playdate.graphics.drawText((time.hour % 12)..":"..time.minute..prefix,0,0)
|
|
else
|
|
playdate.graphics.drawText(time.hour..":"..time.minute,0,0)
|
|
end
|
|
|
|
playdate.graphics.drawText(math.ceil(playdate.getBatteryPercentage()).."%",400-playdate.graphics.getTextSize(math.ceil(playdate.getBatteryPercentage()).."%"),0)
|
|
|
|
imgCover:draw(200-67,30)
|
|
|
|
playdate.graphics.drawText(songTitle, 200 - playdate.graphics.getTextSize(songTitle)/2,180)
|
|
|
|
if math.floor(song:getOffset()) < math.floor(song:getLength()) then playdate.graphics.drawText(math.floor(song:getOffset()*100)/100,1,210) else playdate.graphics.drawText(math.floor(song:getLength()),1,210) end
|
|
playdate.graphics.drawText(math.floor(song:getLength()).."S",370,210)
|
|
|
|
if playdate.buttonJustPressed(playdate.kButtonUp) then
|
|
if timeRate == true then timeRate = false else timeRate = true end
|
|
end
|
|
|
|
if playdate.buttonJustPressed(playdate.kButtonLeft) then
|
|
song:setOffset(0)
|
|
end
|
|
|
|
if playdate.buttonJustPressed(playdate.kButtonB) then
|
|
paused = false
|
|
playbackRate = 1.0
|
|
createMenu(songlist)
|
|
song:stop()
|
|
end
|
|
end |