Code: Select all
dim CurSpeed as single = 0.0
public function ProcessCurves(byval target as integer) as integer
dim speed as integer
dim sChange as integer
speed = CInt(CurSpeed)
if (speed > 0) then
sChange = target - speed
elseif (speed < 0) then
sChange = speed - target
else
sChange = Abs(target)
end if
if (sChange < 0) then
Debug.Print "--- brake spd "; CStr(CurSpeed); " t "; CStr(target); " dV "; CStr(dV);
elseif (sChange > 0) then
Debug.Print "--- accel spd "; CStr(CurSpeed); " t "; CStr(target); " dV "; CStr(dV);
else
Debug.Print "--- keep spd "; CStr(CurSpeed); " t "; CStr(target)
end if
end function
--- brake spd -64.10392 t 14 dV 3.735294
--- accel spd -60.31372 t -8 dV -3.527778
--- brake spd -8.0 t 0 dV 3.735294
So, I add debug like this:
Code: Select all
elseif (speed < 0) then
sChange = speed - target
Debug.Print "- "; CStr(sChange)
else
- 124
--- accel spd -126.0 t -125 dV -3.527778
- 76
--- accel spd -125.0 t -77 dV -3.527778
- -32
--- brake spd -77.0 t 31 dV 3.735294
Now it is really getting weird. Looks like "sChange = speed - target" instead does "sChange = -1 - target". So, I am changing debug format to more descriptive:
Code: Select all
Debug.Print CStr(CurSpeed); " "; CStr(speed); " - "; CStr(target); " = "; CStr(sChange)