Skip to content
Game 3

Brake before you arrive

Fuel is unlimited in this version.

Continue with Let gravity change the speed. We have watched an accelerating fall. Now hold Space to oppose it and try to arrive gently. Fuel is unlimited in this version.

Add lines 80, 90, 97, 105, 128, 155. Replace lines 40, 95, 130, 150, 160.

10 BORDER 0: PAPER 0: INK 7: BRIGHT 1: CLS
20 LET y=400: LET r=4: LET v=0
30 FOR c=0 TO 31: PRINT PAPER 4;INK 0;AT 20,c;"=": NEXT c
40 PRINT AT 0,1;"TOUCHDOWN: SPACE TO BRAKE"
50 PRINT AT r,24;"A"
80 LET burn=0
90 IF INKEY$=" " THEN LET burn=1
95 LET v=v+2-6*burn
96 IF v>60 THEN LET v=60
97 IF v<-30 THEN LET v=-30
100 LET ny=y+v
105 IF ny<300 THEN LET ny=300: LET v=0
110 IF ny>=1900 THEN LET ny=1900
120 LET nr=INT (ny/100)
125 PRINT AT 1,1;"Pos: ";ny;"  ";AT 1,16;"Speed: ";v;"  "
128 LET a$="A": IF burn=1 THEN LET a$="*"
130 PRINT AT r,24;" ";AT nr,24;a$
140 LET y=ny: LET r=nr
150 IF y=1900 THEN IF v<=12 THEN PRINT AT 2,1;"Safe landing!": STOP
155 IF y=1900 THEN PRINT AT 2,1;"Too fast!": STOP
160 PAUSE 2: GO TO 80

A burn changes velocity

INKEY$ checks the keyboard without waiting for an answer. Here we compare it with a string containing one space, " ". That represents Space. An empty string, "", is different: it contains no character.

Each update starts with burn=0. If Space is detected, burn becomes 1. The expression v+2-6*burn always adds gravity’s 2 and subtracts 6 only during a burn. A burning update therefore changes velocity by −4 overall.

Suppose the craft is descending at 30. One burn makes its velocity 26. It is still moving downwards, just more slowly. Holding the engine long enough can make velocity negative, which moves the craft upwards.

Why can a craft with its engine firing still crash into the ground?

Show the explanation

Thrust reduces its downward velocity over several updates; it does not instantly set it to zero. Starting the burn too late can leave too much downward speed at contact. The flame reports engine activity, not a guaranteed safe approach.

Give the movement room

We cap upward velocity at −30. If the proposed position goes above 300, line 105 puts it at 300 and sets velocity to zero. This keeps the craft out of the instrument rows. It is an explicit screen boundary, not an invisible source of fuel or a simulation of an atmosphere.

Line 128 chooses A or * using the same burn decision as the physics. Both occupy one cell, so the engine indicator does not paint over ground below the craft. a$ is a string variable: Sinclair BASIC string names have one letter followed by $.

Judge the arrival

The contact rules now distinguish two outcomes. At position 1900, a velocity of 12 or less is safe; a larger one is too fast. In ordinary play the craft reaches this flat ground from above, so contact is downward. The nested IF on line 150 means that both the contact condition and its speed test must succeed before the success message and STOP execute.

The next line handles the other contact outcome. A failed IF skips the rest of its line, which lets execution reach that second test.

Try a late burn, then start braking higher on the next attempt. Watch velocity approach zero rather than treating the flame as a brake light. RUN resets the starting values. A held key may alter PAUSE timing, so judge the displayed velocity and the approach rather than counting seconds.

An engine held against the ceiling should leave the craft at row 3. Release Space and check that gravity starts it falling again. Keep this unlimited-thrust version: it is a useful place to practise braking before adding fuel pressure.

Sources

Steven Vickers, edited by Robin Bradbeer, ZX Spectrum BASIC Programming, second edition (Sinclair Research, 1983), chapters 3 and 8 (conditions and strings), and chapter 18 (INKEY$ and movement).