Created
April 4, 2016 16:29
-
-
Save myuon/20ff4eb35ee8994ec95977c71642407e to your computer and use it in GitHub Desktop.
※SJISで保存してscript/以下に置く
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--track0:加速度,0,500,50 | |
--track1:Y移動量,-1000,1000,500 | |
--track2:弾性係数,0,10.00,0.80 | |
--track3:閾値,0.1,100,0.1 | |
--check0:高さ0地点からスタート,0; | |
--dialog:バウンド回数,bmax=-1; | |
g = obj.track0 | |
H = obj.track1 | |
e = obj.track2 | |
v = obj.track3 | |
function bounce(t) | |
n = 0 | |
tn = 0 | |
yn = H | |
if (t < 0) then | |
return H | |
else | |
while true do | |
n = n + 1 | |
tn2 = tn + (1 + e) * math.sqrt(2 * yn / g) | |
yn2 = e * e * yn | |
if (tn <= t and t < tn2) then | |
break | |
end | |
if (yn2 < v) then | |
break | |
end | |
tn = tn2 | |
yn = yn2 | |
end | |
sn = tn + math.sqrt(2 * yn / g) | |
if (bmax > 0 and ((n == bmax and t >= sn) or n > bmax)) then | |
return 0 | |
elseif (yn2 < v) then | |
return 0 | |
elseif (tn <= t and t < sn) then | |
return (yn - g * (t - tn) * (t - tn) / 2) | |
else | |
return (e * math.sqrt(2 * g * yn) * (t - sn) - g * (t - sn) * (t - sn) / 2) | |
end | |
end | |
end | |
if obj.check0 then | |
toffset = math.sqrt(2 * H / g) | |
else | |
toffset = 0 | |
end | |
obj.oy = -bounce(obj.time*10 - (obj.index - 1) * 0.2 + toffset) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment