it compiles! it's fucked up but it compiles

sign errors and math errors abound
This commit is contained in:
Kistaro Windrider 2024-02-03 21:10:03 -08:00
parent 525c7e0cb6
commit 16469f0863
Signed by: kistaro
SSH Key Fingerprint: SHA256:TBE2ynfmJqsAf0CP6gsflA0q5X5wD5fVKWPsZ7eVUg8

View File

@ -559,11 +559,11 @@ toyphin = {
} }
mknew(toyphin) mknew(toyphin)
function dive_bloop() function dive_splash(x)
-- TODO: sfx, vfx for dive input -- TODO: sfx, vfx for dive input
end end
function jump_bloop() function jump_splash(x)
-- TODO: sfx, vfx for jump input -- TODO: sfx, vfx for jump input
end end
@ -576,42 +576,42 @@ function landing_splash(x, force, harder)
end end
function toyphin:update() function toyphin:update()
local x, y, dy = self.x, self.y, self.dy
-- entry mode? -- entry mode?
if not self.entered then if not self.entered then
self.x += 1 x += 1
self.entered = self.x >= 16 self.entered = x >= 16
elseif self.exiting then elseif self.exiting then
if self.x > 128 then if x > 128 then
self.exited = true self.exited = true
else else
self.x += 1 x += 1
end end
end end
local y, dy = self.y, self.dy
-- 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 self.state.idle then
if (btnp(0)) then if (btn(2)) then
jump_bloop() jump_splash(x)
dy=-4.125 dy=-4.125
elseif (btnp(1)) then elseif (btn(3)) then
dive_bloop() dive_splash(x)
dy=4.125 dy=4.125
end end
else else
dy += (btnp(1) and 0.1875 or 0) - (btnp(0) and 0.1875 or 0) dy += (btn(3) and 0.1875 or 0) - (btn(2) and 0.1875 or 0)
end end
end end
if (y > 64) dy += 0.375 if (y > 64) dy -= 0.375
if (y < 64) dy -= 0.375 if (y < 64) dy += 0.375
local new_y = y + dy local new_y = y + dy
if new_y <= 64 && y > 64 then if new_y <= 64 and y > 64 then
-- surfacing -- surfacing
surfacing_splash(self.x, -dy, btn(0) and (dy > -4.125)) surfacing_splash(x, -dy, btn(2) and (dy > -4.125))
if btn(0) then if btn(2) then
-- maybe boost -- maybe boost
if dy > -4.125 then if dy > -4.125 then
new_y = 64 + ((dy + y - 64)/dy * -4.125) new_y = 64 + ((dy + y - 64)/dy * -4.125)
@ -619,18 +619,19 @@ function toyphin:update()
end end
else else
-- brake -- brake
if dy > -0.5 then if dy > -1 then
--stabilize --stabilize
new_y = 64 new_y = 64
dy = 0 dy = 0
else else
dy /= 4 dy /= 2
new_y = 48 + new_y/4 new_y = 32 + new_y/2
end end
elseif new_y >= 64 && y < 64 then end
elseif new_y >= 64 and y < 64 then
-- landing -- landing
landing_splash(self.x, dy, btn(1) and (dy < 4.125)) landing_splash(x, dy, btn(3) and (dy < 4.125))
if btn(1) then if btn(3) then
-- maybe boost -- maybe boost
if dy < 4.125 then if dy < 4.125 then
new_y = 64 - ((dy - y + 64)/dy * 4.125) new_y = 64 - ((dy - y + 64)/dy * 4.125)
@ -638,13 +639,14 @@ function toyphin:update()
end end
else else
--brake --brake
if dy < 0.5 then if dy < 1 then
--stabilize --stabilize
new_y = 64 new_y = 64
dy = 0 dy = 0
else else
dy /= 4 dy /= 2
new_y = 80 - new_y/4 new_y = 96 - new_y/2
end
end end
end end
y=new_y y=new_y
@ -666,7 +668,7 @@ function toyphin:update()
if (y == 64 and dy == 0) st = phinstate_nrm if (y == 64 and dy == 0) st = phinstate_nrm
-- test mode -- test mode
--if (btn(5)) self.exiting = true --if (btn(5)) self.exiting = true
self.y, self.dy, self.state = y, dy, st self.x, self.y, self.dy, self.state = x, y, dy, st
end end
-- hitbox for current state -- hitbox for current state