Compare commits

...

2 Commits

Author SHA1 Message Date
54426be303
now it actually works! 2024-01-14 20:06:09 -08:00
84a803b828
fixed it! mostly 2024-01-14 20:02:45 -08:00

View File

@ -130,7 +130,7 @@ function ship:draw()
if (self.dx == 0) return if (self.dx == 0) return
local bd, f = brake_dist(self.dx, self.thrust + self.drag) local bd, f = brake_dist(self.dx, self.thrust + self.drag)
local bdx = self.x+bd-2 local bdx = self.x+bd-2
spr(3, bdx,self.y-3) spr(3, bdx,self.y-2)
print(tostr(f), bdx, self.y - 8, 14) print(tostr(f), bdx, self.y - 8, 14)
end end
@ -177,11 +177,11 @@ function constraints:constrain(s, want)
end end
function brake_dist(v0, brake_max) function brake_dist(v0, brake_max)
local tri_frames = abs(v0/brake_max)&-1 local tri_frames = abs(v0\brake_max)
local chunks = tri_frames * (tri_frames - 1) >> 1 local chunks = tri_frames * (tri_frames - 1) >> 1
local chunk_zone = chunks * brake_max local chunk_zone = chunks * brake_max
local overage = v0 - tri_frames * brake_max local overage = abs(v0) - tri_frames * brake_max
return (chunk_zone + overage * (tri_frames + 1)) * -sgn(v0), (overage > 0) and tri_frames + 1 or tri_frames return (chunk_zone + overage * (tri_frames + 1)) * sgn(v0), (overage > 0) and tri_frames + 1 or tri_frames
end end
function constraints:cycle() function constraints:cycle()