port improvements to autobrake_test too, excluding the weird calc_targets thing

This commit is contained in:
Kistaro Windrider 2024-08-16 19:37:43 -07:00
parent ccb897af24
commit f736f50870
Signed by: kistaro
SSH Key Fingerprint: SHA256:TBE2ynfmJqsAf0CP6gsflA0q5X5wD5fVKWPsZ7eVUg8

View File

@ -136,12 +136,8 @@ function ship:draw()
end
function calc_velocity(v0, t, vmax, drag)
local v1 = v0 + t
local sg = sgn(v1)
v1 -= sg*drag
if (sgn(v1) != sg) return 0
if (abs(v1) > vmax) return sg*vmax
return v1
v0 = mid(v0 + t, vmax, -vmax)
return v0 - mid(drag, -drag, v0)
end
function ship:update()
@ -191,7 +187,7 @@ function constraints:constrain(s, want)
if (bx <= txm) return want
self.color = 8
local overage = bx - txm
want -= overage/(bf+1)
want -= overage/max(bf,1)
if (want < -s.thrust) want = -s.thrust
return want
end