Better-feeling physics constants and behaviors

This commit is contained in:
Kistaro Windrider 2024-02-04 01:15:56 -08:00
parent 373d1d6b11
commit 69dab5482a
Signed by: kistaro
SSH Key Fingerprint: SHA256:TBE2ynfmJqsAf0CP6gsflA0q5X5wD5fVKWPsZ7eVUg8

View File

@ -596,33 +596,33 @@ function toyphin:update()
-- button handling
if self.entered and not self.exiting then
if self.state.idle then
if y >= 61 and y <= 67 and dy < 1 and dy > -1 then
if (btn(2)) then
jump_splash(x)
dy=-4.125
dy=-3.8
elseif (btn(3)) then
dive_splash(x)
dy=4.125
dy=3.8
end
else
dy += (btn(3) and 0.1875 or 0) - (btn(2) and 0.1875 or 0)
dy += (btn(3) and 0.125 or 0) - (btn(2) and 0.125 or 0)
end
end
if (y > 64) dy -= 0.375
if (y < 64) dy += 0.375
if (y > 64) dy -= 0.3
if (y < 64) dy += 0.3
local new_y = y + dy
if new_y <= 64 and y > 64 then
-- surfacing
surfacing_splash(x, -dy, btn(2) and (dy > -4.125))
surfacing_splash(x, -dy, btn(2) and (dy > -3.8))
if btn(2) then
-- maybe boost
if dy > -4.125 then
new_y = 64 + ((dy + y - 64)/dy * -4.125)
dy = -4.125
if dy > -3.8 then
new_y = 64 + ((dy + y - 64)/dy * -3.8)
dy = -3.8
else
dy = (dy - 4.125) / 2
dy = (dy - 7.6) / 3
end
else
-- brake
@ -636,14 +636,14 @@ function toyphin:update()
end
elseif new_y >= 64 and y < 64 then
-- landing
landing_splash(x, dy, btn(3) and (dy < 4.125))
landing_splash(x, dy, btn(3) and (dy < 3.8))
if btn(3) then
-- maybe boost
if dy < 4.125 then
new_y = 64 - ((dy - y + 64)/dy * 4.125)
dy = 4.125
if dy < 3.8 then
new_y = 64 - ((dy - y + 64)/dy * 3.8)
dy = 3.8
else
dy = (4.125 + dy) / 2
dy = (7.6 + dy) / 3
end
else
--brake
@ -659,14 +659,14 @@ function toyphin:update()
y=new_y
local wet, st = y > 64, phinstate_error
if dy < -1.5 then
if dy < -2.5 then
st = wet and phinstate_rise_full or phinstate_jump_full
elseif dy <= -0.5 then
elseif dy <= -1.5 then
st = wet and phinstate_rise_wax or phinstate_jump_wane
elseif dy < 0.5 then
elseif dy < 1.5 then
-- handle idle special case later
st = wet and phinstate_return or phinstate_crest
elseif dy <= 1.5 then
elseif dy <= 2.5 then
st = wet and phinstate_dive_wane or phinstate_fall_wax
else
st = wet and phinstate_dive_full or phinstate_fall_full