alpha 0.1
This commit is contained in:
17
source/utilities/utils.lua
Normal file
17
source/utilities/utils.lua
Normal file
@@ -0,0 +1,17 @@
|
||||
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
|
Reference in New Issue
Block a user