port improvements to autobrake_test too, excluding the weird calc_targets thing
This commit is contained in:
parent
ccb897af24
commit
f736f50870
@ -136,12 +136,8 @@ function ship:draw()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function calc_velocity(v0, t, vmax, drag)
|
function calc_velocity(v0, t, vmax, drag)
|
||||||
local v1 = v0 + t
|
v0 = mid(v0 + t, vmax, -vmax)
|
||||||
local sg = sgn(v1)
|
return v0 - mid(drag, -drag, v0)
|
||||||
v1 -= sg*drag
|
|
||||||
if (sgn(v1) != sg) return 0
|
|
||||||
if (abs(v1) > vmax) return sg*vmax
|
|
||||||
return v1
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function ship:update()
|
function ship:update()
|
||||||
@ -191,7 +187,7 @@ function constraints:constrain(s, want)
|
|||||||
if (bx <= txm) return want
|
if (bx <= txm) return want
|
||||||
self.color = 8
|
self.color = 8
|
||||||
local overage = bx - txm
|
local overage = bx - txm
|
||||||
want -= overage/(bf+1)
|
want -= overage/max(bf,1)
|
||||||
if (want < -s.thrust) want = -s.thrust
|
if (want < -s.thrust) want = -s.thrust
|
||||||
return want
|
return want
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user