port improvements to autobrake_test too, excluding the weird calc_targets thing
This commit is contained in:
		| @@ -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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user