Skip to content

Reverse direction

  • The Craft

A player presses left while travelling right. Should that request immediately reverse velocity, brake the existing motion, or use a different turning rule? Compare two rates for braking against current motion.

Both ships receive the same input. Changing the slider resets them. Open “Inspect one update” to pause and trace a single step. This is a browser model, not a measurement of a particular retro computer.

Movement rule source (JavaScript)

Watch the sign of velocity

Run the comparison. Both ships receive Right for 0.8 seconds, long enough to reach +240 units/s. They then receive Left for two seconds before release.

The reference brakes against its motion at 600 units/s². Your ship starts with reversal braking of 240. Both still accelerate from rest and brake on release at 600. Only the opposing-input case changes.

Your ship continues right for a while after Left is pressed. Watch its velocity fall towards zero. That is a response to input: it is slowing down. Once it stops, the next update accelerates it left.

Separate input from motion

Code
IF velocity * input < 0 THEN
    LET target = 0
    LET rate = reversalBraking
ELSE
    LET target = input * 240
    LET rate = 600
END

Opposite signs produce a negative product: positive velocity with Left (−1), or negative velocity with Right (+1). Released input gives a product of zero, so it uses the normal release branch. A stationary ship also uses normal acceleration.

Approach the selected target by at most rate × elapsedSeconds, then update position using the new velocity. This version reaches zero before beginning motion in the other direction; it does not spend leftover braking capacity on acceleration within the same update.

Velocity is +240 and Left is pressed. With reversal braking of 240 units/s², what happens in the next 1/60-second update?

Show the explanation

Velocity decreases by 4 to +236. Position still increases, by 236/60 ≈ 3.933 units. Directional input is negative, but motion remains positive until enough updates have reduced velocity to zero.

From +240, the default setting takes one second to reach zero. The reference takes 0.4 seconds. You can trace the first update with the inspector; Reset restores both ships and their input to the same starting state.

Choose a rule for a purpose

Compare a cursor, a hovercraft and a character on a narrow ledge. Which benefits from instant stopping? Which makes planning a turn part of the challenge? State the intended action before choosing a number.

The three-ship playground combines these choices into distinct presets. Return to it and explain the differences using acceleration, release braking and reversal, rather than relying only on “responsive”, “slippery” or “heavy”. Its presets use a different reversal rule: they approach the opposite velocity directly, so the zero-first rule here is an alternative to compare.

A useful playtest asks someone to reach and stop at the marker. Observe overshoots and corrections, change one rule, and try again. The best setting is the one that serves the action you intend, with feedback that lets the player understand it.