37 lines
1.5 KiB
Lua
37 lines
1.5 KiB
Lua
---@meta
|
|
|
|
---@class Shake : Object
|
|
---@field amplitude number The maximum shake strength in pixels
|
|
---@field frequency number How many shake samples per second
|
|
---@field duration number Duration of the shake in milliseconds
|
|
---@field samples number[] Pre-generated noise samples for smooth interpolation
|
|
---@field start_time number Timestamp (ms) when shake started
|
|
---@field t number Current elapsed time in milliseconds
|
|
---@field shaking boolean Whether the shake is still active
|
|
Shake = {}
|
|
|
|
---Creates a new camera shake effect.
|
|
---@param amplitude number Maximum shake offset in pixels
|
|
---@param frequency number Samples per second (higher = more erratic)
|
|
---@param duration number Duration in milliseconds
|
|
function Shake:new(amplitude, frequency, duration) end
|
|
|
|
---Updates the shake timer. Call every frame.
|
|
---@param dt number Delta time in seconds (from love.update)
|
|
function Shake:update(dt) end
|
|
|
|
---Gets the current shake amplitude at time `t`.
|
|
---If `t` is not provided, uses current elapsed time.
|
|
---@param t? number Optional time in milliseconds
|
|
---@return number amplitude Current shake strength (0 when finished)
|
|
function Shake:getAmplitude(t) end
|
|
|
|
---Internal: Gets noise value at sample index.
|
|
---@param s number Sample index (float allowed for interpolation)
|
|
---@return number noise Value between -1 and 1
|
|
function Shake:noise(s) end
|
|
|
|
---Internal: Linear decay envelope (1 → 0 over duration).
|
|
---@param t number Time in milliseconds
|
|
---@return number decay_factor From 1.0 down to 0.0
|
|
function Shake:decay(t) end
|