Skip to content

Build up speed

  • The Craft

A ship can acknowledge a press immediately without reaching full speed immediately. Change how quickly velocity approaches its target, while keeping the release rule simple.

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)

Change acceleration alone

Hold right. The reference reaches 240 units per second on its first update. Your ship starts more slowly and builds towards that same speed. Release: both stop instantly. That deliberate stopping rule isolates the change we are studying.

At the default acceleration of 240 units/s², velocity increases by 240 units/s over one second of held input. The symbol s² means “seconds squared”; here it describes a change in velocity per second, not a distance.

Run the comparison at 120, then 480 units/s². Predict which setting reaches full speed sooner. The top speed remains 240 in both cases: more acceleration does not increase that limit.

Approach a target without passing it

For each 1/60-second update, the default setting permits a velocity change of 240 × 1/60 = 4 units/s. Starting from rest, the first velocities are 4, 8, 12 and 16.

Code
LET target = input * 240
LET change = acceleration * elapsedSeconds
IF velocity < target THEN
    LET velocity = MIN(target, velocity + change)
ELSE
    LET velocity = MAX(target, velocity - change)
END

MIN chooses the smaller value; MAX chooses the larger. They prevent an update from passing the target. The same rule can approach a negative target when you hold left. Released input takes a separate branch that sets velocity to zero.

Reset, open Inspect one update, and step Right twice. Your ship moves by 4/60 units on the first update, then 8/60 on the second. The position changes grow because we add the new velocity each time.

Velocity is 238, target velocity is 240, and this update allows a change of 4. What should the next velocity be?

Show the explanation

240, not 242. Take the smaller of the target (240) and the proposed velocity (242). Without that limit, the ship could alternate above and below its intended speed.

Read the difference before naming it

Low acceleration asks the player to start moving earlier. High acceleration allows quicker corrections. Describing one as “heavy” can be useful, but the label does not explain the rule. Watch velocity and name what actually changes.

Our instant stopping may now feel inconsistent with the gradual start. Keep it for this comparison; next we change what happens when input is released.