Skip to content

Instantly share code, notes, and snippets.

@GarethIW
Last active July 29, 2022 17:11
Show Gist options
  • Save GarethIW/4f5a0215300d41f814194e9a96cc2a4f to your computer and use it in GitHub Desktop.
Save GarethIW/4f5a0215300d41f814194e9a96cc2a4f to your computer and use it in GitHub Desktop.
import "CoreLibs/graphics"
import "CoreLibs/crank"
local numFrames=55
local frames={}
local currentFrame=1
playdate.display.setRefreshRate(50)
for i=1,numFrames do
table.insert(frames, playdate.graphics.image.new("images/frame ("..i..")"))
end
function playdate.update()
playdate.graphics.setColor(playdate.graphics.kColorBlack)
playdate.graphics.fillRect(0, 0, playdate.display.getWidth(), playdate.display.getHeight())
frames[currentFrame]:draw(0,8)
end
function playdate.cranked(change, acceleratedChange)
currentFrame+=playdate.getCrankTicks(10)
if currentFrame<1 then currentFrame=1 end -- why u no math.clamp() lua?
if currentFrame>numFrames then currentFrame=numFrames end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment