EasyManua.ls Logo

Sinclair QL - Page 102

Sinclair QL
135 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
MULTIPLE DECISIONS - SELect
Where there are three or more possible actions and none is dependant on a previous choice the
natural structure to use is SELect which enables selection from any number of possibilities.
EXAMPLE
A magic snake grows without limit by adding a section to its front. Each section may be up to twenty
units long and may be a new colour or it may remain the same. Each new section must grow in one of
the directions North, South, East, or West. The snake starts from the centre of the window.
Method
At any time while the snake is still on the screen you choose a random length and ink colour easily.
The direction may be selected by a number 1,2,3 or 4 as shown:
Design:
Select PAPER
Set snake to centre of window
REPeat
Choose direction, colour length of growth
FOR unit = 1 to growth
Make snake grow north, south, east or west
IF snake is off window THEN EXIT
END FOR
END REpeat
PRINT end message
Program:
100 REMark Magic Snake
110 PAPER 0 : CLS
120 LET across = 50 : up = 50
130 REPeat snake
140 LET direction = RND(l TO 4) : colour = RND(2 TO 7)
150 LET growth = RND(2 TO 20)
160 INK colour
170 FOR unit = 1 TO growth
180 SELect ON direction
190 ON direction = 1
200 LET up = up + 1
210 ON direction = 2
220 LET across = across + 1
230 ON direction = 3
240 LET up = up - 1
250 ON direction = 4
260 LET across = across - 1

Other manuals for Sinclair QL

Related product manuals