Sélectionner une révision Git
jump_frz.lua 1,66 Kio
require "baka-fx.util"
--[[
[Description]
A rotation with a far away \org and a small \frz,
mimicking a straight vertical jump.
[Usage]
jump_frz(base_y, height, dur)
jump_frz(base_y, height, dur, a)
jump_frz(base_y, height, dur, t1, t2)
jump_frz(base_y, height, dur, t1, t2, a)
[Arguments]
base_y: vertical coordinate for the start and end of the jump
height: total height of the jump
dur: total duration of the jump
t1: duration between the start of the syl/line and the start of the jump
t2: duration between the end of the jump and dur
a: acceleration for the vertical movement (works the same as \t's)
[Notes]
A chart is worth a thousand words:
vertical
position
^
|
base_y
+ height - x-----x
| / \
base_y - x x
| ' ' ' '
+-------0-t1---t2-dur---> time
--]]
function jump_frz(base_y, height, dur, ...)
local radius = 100000
local rot = height / radius * 180 / math.pi
local a = 1
local t1 = dur / 2
local t2 = dur / 2
local args = { ... }
-- Checking arguments
if #args == 1 then
a = args[1] > 0 and args[1] or a
end
if #args >= 2 then
t1 = clamp(args[1], 0, dur)
t2 = clamp(args[2], 0, dur - t1)
end
if #args >= 3 then
a = args[3] > 0 and args[3] or a
end
local org = tag("org", -radius, base_y)
local up = tag("t", 0, t1, a, tag("frz", rot))
local down = tag("t", dur - t2, dur, 1 / a, tag("frz", 0))
if t1 == 0 and t2 == 0 then return org .. tag("frz", rot) end
if t1 == 0 then return org .. tag("frz", rot) .. down end
if t2 == 0 then return org .. tag("frz", 0) .. up end
return org .. tag("frz", 0) .. up .. down
end