fpv/source/utilities/utils.lua

18 lines
594 B
Lua
Raw Normal View History

2024-06-10 01:50:27 +03:00
function round(number)
local formatted = string.format("%.2f", number)
return formatted
end
function screenShake(shakeTime, shakeMagnitude)
local shakeTimer = playdate.timer.new(shakeTime, shakeMagnitude, 0)
shakeTimer.updateCallback = function(timer)
local magnitude = math.floor(timer.value)
local shakeX = math.random(-magnitude, magnitude)
local shakeY = math.random(-magnitude, magnitude)
playdate.display.setOffset(shakeX, shakeY)
end
shakeTimer.timerEndedCallback = function()
playdate.display.setOffset(0, 0)
end
end