BBC BASIC 2.31 for the Tatung Einstein, showing DRIFT, the text adventure the course builds, in the middle of a game
← Back to Courses
module
27

Running Out Of Air

Introduction

DRIFT can be won, but not lost, so there is no hurry. Wander about for as long as you like, and the ship waits. A game needs a clock. Here it is the ship's air: thirty turns of it, one used with every command, shown before every question.

The Air

AIR% starts at 30, in line 1060. PROCSTATUS prints it on a black band before each WHAT NOW?. PROCAIR takes one off after each turn, warns when there are 10 left, and at 0 sets OVER% to 2 - the loop's way of knowing the game was lost.

Line 100 only runs PROCAIR while the game is still going, so winning on your last breath is still winning.

Three Endings

OVER% now has three meanings, and PROCFINISH deals with each, in one place:

OVER%Meaning
1the code was right - won, and the air left over is the score
2the air ran out - lost
3the player typed QUIT

Line 120, which printed S26's one-line win, is replaced by the call to PROCFINISH.

The Code

LOAD "ADV7". Add these lines, replacing 120 and 1060:

60 PROCSTATUS
100 IF OVER%=0 THEN PROCAIR
120 PROCFINISH
1060 R%=1:POWER%=0:LOCK%=0:OVER%=0:AIR%=30
4000 DEF PROCSTATUS
4010 COLOUR 129:PRINT "AIR ";AIR%;" ";:COLOUR 128:PRINT
4020 ENDPROC
4100 DEF PROCAIR
4110 AIR%=AIR%-1
4120 IF AIR%=10 THEN PRINT "WARNING: AIR RUNNING LOW."
4130 IF AIR%=0 AND OVER%=0 THEN OVER%=2
4140 ENDPROC
4200 DEF PROCFINISH
4210 IF OVER%=1 THEN PROCWRAP("THE ENGINES ROAR INTO LIFE. THE SHIP TURNS FOR HOME. YOU HAVE MADE IT."):PRINT "AIR TO SPARE: ";AIR%
4220 IF OVER%=2 THEN PROCWRAP("THE AIR IS GONE. THE SHIP DRIFTS ON, SILENT, AMONG THE STARS.")
4230 IF OVER%=3 THEN PRINT "YOU GIVE UP."
4240 ENDPROC

Starting from

LOAD "ADV7" from S26. When it works, SAVE "ADV8".

What you should see

AIR 30 on a black band above the first WHAT NOW?, one less each time. Win, and the ending tells you how much air you had left. Waste your turns - type LOOK thirty times - and it ends like this:

AIR 1
WHAT NOW? LOOK
CRYO BAY
...
YOU CAN SEE A DATA PAD.
THE AIR IS GONE. THE SHIP DRIFTS ON,
SILENT, AMONG THE STARS.
>

The air runs out

The walkthrough in S26 wins with 18 to spare.

Change One Thing

  • Make the air start at 3 in line 1060. How many commands do you get?
  • Change line 4120 to warn at 25. When does the warning come?
  • Type QUIT. Which ending is it?

Exercises

27.1 Make the game harder: find the smallest amount of air the walkthrough in S26 can still win with.

27.2 Make the warning say how much air is left: WARNING: 10 AIR LEFT.

Worked solutions are in Appendix II.

When It Goes Wrong

SymptomCause
The game never ends when the air runs outLine 100, or PROCAIR's line 4130, is missing.

Summary

AIR% falls by one a turn and is shown on a black band. At 0 the game is lost. OVER% says how it ended - 1 won, 2 lost, 3 quit - and PROCFINISH says so. Save it as ADV8.

Next

S28, Finishing Touches - a title screen, a sound, and the ship's own noises.

Get the Newsletter

New guides, disk images and community finds, roughly once a quarter. No spam, we promise, this isn't Tatung's marketing department.
Your subscription could not be saved. Please try again.
Your subscription has been successful.

Newsletter

Subscribe to our newsletter and stay updated.