Compare commits

..

2 Commits

View File

@ -596,33 +596,33 @@ function toyphin:update()
-- button handling -- button handling
if self.entered and not self.exiting then 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 if (btn(2)) then
jump_splash(x) jump_splash(x)
dy=-4.125 dy=-3.8
elseif (btn(3)) then elseif (btn(3)) then
dive_splash(x) dive_splash(x)
dy=4.125 dy=3.8
end end
else 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
end end
if (y > 64) dy -= 0.375 if (y > 64) dy -= 0.3
if (y < 64) dy += 0.375 if (y < 64) dy += 0.3
local new_y = y + dy local new_y = y + dy
if new_y <= 64 and y > 64 then if new_y <= 64 and y > 64 then
-- surfacing -- 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 if btn(2) then
-- maybe boost -- maybe boost
if dy > -4.125 then if dy > -3.8 then
new_y = 64 + ((dy + y - 64)/dy * -4.125) new_y = 64 + ((dy + y - 64)/dy * -3.8)
dy = -4.125 dy = -3.8
else else
dy = (dy - 4.125) / 2 dy = (dy - 7.6) / 3
end end
else else
-- brake -- brake
@ -632,19 +632,18 @@ function toyphin:update()
dy = 0 dy = 0
else else
dy /= 2 dy /= 2
new_y = 32 + new_y/2
end end
end end
elseif new_y >= 64 and y < 64 then elseif new_y >= 64 and y < 64 then
-- landing -- 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 if btn(3) then
-- maybe boost -- maybe boost
if dy < 4.125 then if dy < 3.8 then
new_y = 64 - ((dy - y + 64)/dy * 4.125) new_y = 64 - ((dy - y + 64)/dy * 3.8)
dy = 4.125 dy = 3.8
else else
dy = (4.125 + dy) / 2 dy = (7.6 + dy) / 3
end end
else else
--brake --brake
@ -654,21 +653,20 @@ function toyphin:update()
dy = 0 dy = 0
else else
dy /= 2 dy /= 2
new_y = 96 - new_y/2
end end
end end
end end
y=new_y y=new_y
local wet, st = y > 64, phinstate_error 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 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 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 -- handle idle special case later
st = wet and phinstate_return or phinstate_crest 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 st = wet and phinstate_dive_wane or phinstate_fall_wax
else else
st = wet and phinstate_dive_full or phinstate_fall_full st = wet and phinstate_dive_full or phinstate_fall_full