Bottom     Previous     Contents

6 Pictures

The programs in this chapter make use of many of the techniques described in the preceding chapters to create four quite complex pictures. Each program is composed of a number of procedure calls that deal with different aspects of the picture. In this way a complicated view is built up from simple parts, each of which can be written and tested separately.

Windy field

Here is a program that uses both horizontal and vertical scrolling to produce an animated picture. The program draws first a view of a windy field above which clouds drift across the sky. Next, the clouds sink below the horizon and the view shifts upwards to the sun.

Scrolling the screen in this way is a neat way of moving from one scene to the next. This technique could also be used in a wider context to clear the screen while avoiding the use of the rather sudden CLS or CLG commands.

The program is built up from a series of procedures, each one drawing a different part of the view or performing a special action. The main program is quite short and is described below. The procedure declarations that follow could be in any order; these give the details of how to draw a particular object.

The colour scheme chosen for the view is very much a matter of individual taste. You can easily alter the way the palette is set up at lines 30 and 210, or you could write a procedure that would read in logical and physical colour numbers and alter the palette according to the numbers supplied each time the program is run. This way you can draw the picture and {:hen experiment with different colour schemes Interactively.

FIELD

0 REM Windy field

20 MODE1

30 VDU23;10,32;0;0;0;

40 VDU19,0,4;0;19,2,2;0;

50 WIND%=0

60 FORY%=860 TO 700 STEP -40

70 PROCCLOUD(200+RND(870),Y%,100+RND(

100),80+RND(20),TRUE,3,0)

80 NEXT

90 REPEAT

100 WIND%=WIND%-1

110 VDU23;13,WIND%;0;0;0;

120 A=INKEY(12)

130 UNTIL WIND%=0

140 PROCGROUND(16)

150 VDU28,0,9,39,0

160 COLOUR128

170 A=INKEY(300)

180 PROCDOWN(10,80)

190 VDU28,0,31,39,10

200 PROCDOWN(22,0)

210 VDU19,2,3;0;19,3,7;0;

220 PROCSUN(600,700,1000,TRUE,3)

230 PROCSUN(600,700,200,FALSE,1)

240 PROCCLOUD(400,600,300,200,FALSE,2,

3)

250 A=INKEY(300)

260 REPEATVDU19, RND(4)-1, RND(8)-1;0;

:A=INKEY(200):UNTIL FALSE

270 END

Description of program

30	Remove the flashing text cursor.
40	Change the palette so that logical colours 0 and 2 appear as blue and green.
50	The variable WIND% will determine how far the screen has been scrolled. It is altered in PROCCLOUD as the clouds are moved.
60-80	Draw some white clouds, scrolling the screen as they are drawn.
90-130	This loop scrolls the screen back to its orignal position.
110	Re-program register 13 of the 6845 video controller chip, with the value of WIND%.
	The effect of this is to move the portion of memory displayed on the screen.
140	Draw the ground.
150	Define a text window around the sky.
160	Set the text background colour to logical colour 0, the same colour as the sky,
170	Wait 3 seconds, unless a key is pressed.
180	Scroll the sky down so that the clouds sink below the horizon.
190	Define a text window around the ground.
200	Quickly scroll the ground down to leave an empty blue screen. change the palette to make logical colours 2 and 3 appear as yellow and white.
220	Draw the rays in white.
230	Draw the sun in red.
240	Draw a cloud to slightly obscure the sun.
260	Sit there changing the palette at random.

PROCDOWN

This is a procedure that scrolls the current text window downwards. The procedure takes two parameters: N% and D%. N% determines how far to scroll the window and D% specifies the delay between each movement.

280 DEFPROCDOWN(N%,D%)

290 FORI%=1 TO N%

300 VDU11

310 A=INKEY(D%)

320 NEXT

330 ENDPROC

Description of PROCDOWN

290	Each time around this loop the text window scrolls down one line.
300	This scrolls the screen down one line. We assume the text cursor is at the top left-hand corner of the window when PROCDOWN is called.

PROCGROUND

This draws the field, which consists of a solid background colour and lines that give the impression of depth as they converge towards the horizon. The background is filled in very rapidly by defining a text window around the region, and then clearing the text window wi th the col our set to be the text background colour.

340 DEF PROCGROUND(S%)

350 VDU28,0,31,39,10

360 COLOUR129

370 CLS

380 VDU26

390 GCOL0,2

400 VDU29,640;0;

410 MOVE-640,700:DRAW640,700

420 FORX%=-640 TO 640 STEP S%

430 MOVEX%,700:DRAW4*X%,0

440 NEXT

450 ENDPROC

Description of PROCGROUND

350	Define a text window around the ground.
360	Select text background colour to be logical colour 1.
370	Clear the text area, thus filling the region red.
380	Get rid of the text window.
390	This will be the colour of the lines.
400	Move the origin to the centre of the bottom line of the screen.
410	Draw a line along the horizon.
420-440	Draw lines from the horizon to the bottom of the screen, spreading out to give an impression of depth.

PROCCLOUD

This procedure draws a cloud. The cloud outline is obtained by tracing round a small circle as the centre of the circle moves round a larger circle. It takes 7 parameters:

X% is the absolute X-coordinate of the centre of the

cloud.

Y% is the absolute Y--coordinate of the centre of the

cloud.

SX% is the size of the cloud in the X-direction.

SY% is the size of the cloud in the Y--direction.

SCROL% is a boolean that determines whether to scroll the screen sideways as the cloud is being drawn.

C1% is the logical colour of the solid centre of the

cloud.

C2% is, the logical colour of the line around the edge

of the cloud.

460 DEFPROCCLOUD(X%,Y%,SX%,SY%,SCROL%,C1%,C2%)

470 VDU29,X%;Y%;

480 L%=6+RND(8)

490 MOVE0,0:MOVESX%+SX%/L%,0

500 X1%=SX%+SX%/10:Y1%=0

510 IF WIND%>120 THEN S%=-1 ELSE S%=1

520 FORI=0TO 6.3 STEP 0.1

530 IF SCROL% THEN VDU23;13,WIND%,0;0;

0;:WIND%=WIND%+S%

540 X%=SX%*COS(I)+SX%/L%*COS(I*L%)

550 Y%=SY%*SIN(I)+SY%/L%*SIN(I*L%)

560 GCOL0,C1%

570 MOVE32,12:PLOT85,X%,Y%

580 MOVEX1%,Y1%

590 GCOL0,C2%:DRAWX%,Y%

600 X1%=X%:Y1%=Y%

610 NEXT

620 VDU29,0;0;

630 ENDPROC

Description of PROCCLOUD

470	Move the origin to the centre of the cloud.
480	L% controls the number of lumps the cloud will have.
490	Move to the centre and then to the first point on the edge.
500	(Xl%,Yl%) is the first point on the edge of the cloud; as we trace round the cloud this will always be one step behind the point (X%,Y%).
510	Scroll the screen to the left or the right, as required (this prevents the screen from getting too far out of place).
520	I is the angle that measures how far round the cloud we are. 6.3 is approximately PI*2.
530	Scroll the screen if required.
540-550	Calculate the next point along the edge.
560	Select the interior colour (silver not allowed!).
570	Move to a point inside the cloud and fill a triangle to the edge.
580	Move back to the previous edge point.
590	Select the edge line colour and draw along the cloud edge.
600	Move (Xl%,Yl%) along the edge.
620	Return the origin to the usual place.

PROCSUN

This procedure will either draw a solid circular sun or a circle of rays reaching out from the central point. The boolean variable RAYS% determines which to draw.

The parameters are described below: (X%,Y%) is the absolute position of the centre of circle or rays.

S% is the radius of the circle.

RAYS% is either TRUE or FALSE; draw rays or draw a solid circle.

C% is the logical colour to be used.

640 DEFPROCSUN(X%,Y%,S%,RAYS%,C%)

650 VDU29,X%;Y%;

660 GCOL0,C%

670 MOVE4,12

680 T%=TRUE

690 FORA=0 TO 6.3 STEP 0.1

700 MOVE0,0

710 X%=S%*SIN(A)

720 Y%=S%*COS(A)

730 IF RAYS% AND T% THEN MOVE X%,Y% EL

SE PLOT 85,X%,Y%

740 T%=NOT T%

750 NEXT

760 ENDPROC

Description of PROCSUN

650	Put the origin at the centre of the sun.
660	Select the colour specified.
670	Define a point inside the sun.
680	T% toggles on and off as the rays are drawn.
690	Go round a circle. (X%,Y%) is a point on the edge of the circle .
730	Either fill a triangle to the edge, or leave a gap between rays.
740	Toggle T%.

Merry-go-round

This program draws a multi-coloured merry-go-round. The merry-go-round has a base, a roof with a flag on the top and four horses. These are drawn by the procedures PROCEASE, PROCTOP, PROCELAG and PROCHORSE.

The routine PROCRECT fills in a rectangle in a given colour . It does this by defining a graphics window around the region and then clearing this region with the colour required as the graphics background colour. This method must be used with care since if any point of the window is off the screen the entire screen will be filled. Despite this, the rectangular fill using a window is a useful complement to the more common triangle fill technique. A similar method can be used with text windows; these give much faster filling but the window cannot be positioned to a single pixel resolution.

MERRYGO

0 REM Merry-Go-Round

20 MODE2

30 VDU5

40 PROCRECT(0,600,1272,1020,6)

50 PROCRECT(0,0,1272,600,2)

60 PROCBASE(640,150)

70 PROCTOP(640,760)

80 PROCFLAG(640,868)

90 FORX%=460 TO 820 STEP 360

100 PROCHORSE(X%,300,90,5,FALSE)

110 PROCRECT(X%,340,X%+8,710,3)

120 NEXT

130 PROCRECT(600,150,680,760,1)

140 FORX%=340 TO 940 STEP 600

150 PROCHORSE(X%,200,110,0,TRUE)

160 PROCRECT(X%,250,X%+16,760,3)

170 NEXT

180 END

Description of program

40 Draw the sky.

50 Draw the ground.

60 Draw the base of the merry-go-round.

70 Draw the top.

80 Draw a flag.

90-120 This loop draws two horses, facing right, on the far side of the platform.

130 Draw the central pillar.

140-170 Draw the front two horses facing left.

PROCRECT

This procedure fills in a rectangle in a given colour. It does this by defining a graphics window around the area to be filled, and then clearing the graphics screen with the colour specified.

190 DEFPROCRECT(X%,Y%,SX%,SY%,C%)

200 VDU24,X%;Y%;SX%;SY%;

210 GCOL0,128+C%

220 CLG

230 VDU26

240 ENDPROC

Description of PROCRECT

200	Define graphics window.
210	Select graphics background colour.
220	Fill the window with that colour.
230	Get rid of the window.

PROCBASE

The base consists of two parts; the floor drawn in blue, and the side.

This procedure draws a perspective view of the base, which can be thought of as a rather flat drum, or a very large coin.

250 DEF PROCBASE(X%,Y%)

260 VDU29,X%;Y%;

270 FORX%=-500 TO 500 STEP 4

280 Y%=60-(X%*X%)/4000

290 MOVE X%,Y%

300 GCOL0,4:PLOT1,0,-2*Y%

310 GCOL0,1:PLOT1,0,-50

320 NEXT

330 ENDPROC

Description of PROCBASE

260	Move the origin to the centre of the base.
270	The base is 1000 units across - it is filled in by drawing lots of lines next to each other.
280	Calculate the Y-coordinate of the next line.
290	Move to the top of the next line.
300	Draw the floor in blue.
310	Draw the edge.

PROCTOP

The top of the merry-go-round is similar to the base. The main difference is that the roof has turrets along its side.

340 DEFPROCTOP(X%,Y%)

350 VDU29,X%;Y%;

360 FORX%=-500 TO 500 STEP 4

370 Y%=60-(X%*X%)/4000

380 MOVEX%,-Y%

390 GCOL0,4

400 PLOT 1,0,2*Y%

410 GCOL0,1

420 IF((500+X%)DIV90)MOD2=1 THEN 440

430 PLOT 1,0,80:PLOT0,0,-80:GOTO450

440 PLOT1,0,50:PLOT0,0,-50

450 NEXT

460 VDU26

470 ENDPROC

Description of PROCTOP

350-400	As for the first few lines of PROCEASE.
420	Decide whether to draw a line in a turret.
430	Draw a turret line.
440	Draw a line in the gap between turrets.
460	The VDU 26 statement causes a return to the default text and graphics windows; one side effect of this, utilised here, is to return the origin to its normal place.

PROCFLAG

This draws a flag with its base at the point (X%,Y%).

480 DEFPROCFLAG(X%,Y%)

490 PROCRECT(X%,Y%,X%+16,Y%+120,5)

500 MOVEX%+16,Y%+120

510 GCOL0,3:PLOT0,500,-30:PLOT81,-500,-30

520 ENDPROC

Description of PROCFLAG

490	Draw the flag-pole.
500	Move to the top of the pole.
510	Move to the tip of the flag and fill the flag in.

PROCHORSE

This draws a horse. The procedure requires the following parameters:

(X%,Y%) is the location of the horse.

S% controls how large the horse will be.

C% is the logical colour of the body of the horse.

RIGHT% is a boolean value that determines the direction the horse is facing.

530 DEF PROCHORSE(X%,Y%,S%,C%,RIGHT%)

540 PROCRECT(X%-S%,Y%,X%+S%,Y%+S%/1.5,C%)

550 VDU29,X%;Y%;

560 GCOL0,C%

570 MOVE0,0

580 FORI%=-S% TO S% STEP 2*S%

590 MOVEI%,-S%/8:PLOT85,1.5*I%,-S%/8

600 MOVE2*I%,-S%/4:PLOT85,2.5*I%,-S%/4

610 MOVE1.5*I%,0:PLOT85,0,0

620 NEXT

630 IF RIGHT% THEN D%=-S% ELSE D%=S%

640 MOVE D%/2,S%/1.5

650 MOVE D%,S%*2/1.5

660 PLOT 85,D%,S%/1.5

670 MOVED%*1.5,S%*1.2/1.5

680 MOVED%,S%*1.2/1.5

690 PLOT85,D%*1.5,S%

700 PLOT85,D%,S%*1.2

710 MOVE -D%,S%/1.5

720 MOVE-D%*2,S%/1.5

730 PLOT85,-D%*2,S%/2

740 GCOL0,7:PLOT69,D%*1.2,S%

750 VDU29,0;0;

760 PROCRECT(X%-S%/3,Y%+S%/3,X%+S%/3,Y

%+S%/1.5,3)

770 ENDPROC

Description of PROCHORSE

540	Draw the body.
550-520	Draw the legs.
630	Is the horse to be facing right or left?
640-700	Draw the head.
710-730	Draw the tail.
740	Draw the eye.
760	Draw the saddle.

Rainbow

This program draws a view of a rainbow spanning a road that shoots through a snow-covered grassland. There is plenty of scope for adding more features to this rural scene. For example clouds, hills, houses or trees might enhance the bleak landscape.

Even the simplest picture can be dramatically improved by introducing some animation. Here clouds could be made to blow across the sky and their shadows could drift across the grass. The large number of logical colours make animated effects possible by drawing several different picture frames. Palette changes can then be used to reveal each of these in turn.

RAINBOW

0 REM Rainbow

20 MODE2

30 VDU5

40 PROCSKY(550)

50 PROCBOW(600,550,80,32)

60 PROCGRASS(550)

70 PROCROAD(600,550)

80 END

All that remains to do now is to declare the procedures that are to be called above. The order in which these procedures are declared has no effect on the operation of the program.

PROCBOW

This draws a rainbow whose centre is at the point (X%,Y%). D% is the radius of the innermost band of colour in the rainbow. S% is the thickness of the bands. The rainbow is drawn by filling in small triangles formed between the two concentric circles on the edges of each band of colour.

90 DEFPROCBOW(X%,Y%,D%,S%)

100 VDU29,X%;Y%;

110 FORI%=0TO10

120 MOVE-(I%*S%+D%),0:MOVE-((I%+1)*S%+

D%),0

130 GCOL0,(I% MOD 5)+1

140 FORA=-PI/2-0.1 TO PI/2+0.2STEP 0.2

150 PLOT85,(D%+I%*S%)*SIN(A),(D%+I%*S%

)*COS(A)

160 PLOT85,((I%+1)*S%+D%)*SIN(A),((I%+

1)*S%+D%)*COS(A)

170 NEXT A,I%

180 ENDPROC

Description of PROCBOW

100	Move the origin to the centre of the rainbow.
110	Each time round this loop we draw a band of colour.
120	Move to the left-hand side of the rainbow. Two moves are needed since PLOT 85 fills up to the last two points visited.
130	Select the colour for that band. The order of colours is not the same as for a real-world rainbow.
140	Move round the circle by increasing the angle A.
150	Fill in the triangle whose tip is on the inner circle.
160	Do the same moving to the outer circle.
170	carry on until all the bands have been drawn.

PROCGRASS

This procedure draws a perspective view of snow covered grass up to the line Y=H%. First the grass is drawn by simply filling the area green, next the snow covering is produced using a dot shading method.

190 DEFPROCGRASS(H%)

200 VDU29,0;0;

210 GCOL0,2

220 MOVE0,0:MOVE0,H%:PLOT85,1300,H%

230 MOVE1300,0:PLOT85,0,0

240 GCOL0,7

250 FORX%=0TO1300STEP8

260 FORY%=4TOH%STEP4

270 IF RND(H%)<Y% THEN PLOT 69,X%,Y%

280 NEXT Y%,X%

290 ENDPROC

Description of PROCGRASS

200	Make sure the origin is in the right place.
210-230	Fill the grass area green.
250	Move along the x-axis drawing lines of dots. In MODE 2 pixels are 8x4 coordinate units.
260	Draw a line of dots to the horizon.
270	Make the dots become denser as we approach the horizon.

PROCROAD

This draws a straight road from the origin to a point (X%,Y%). The road consists of a dark background (the tarmac surface) and a central white line (no overtaking).

300 DEFPROCROAD(X%,Y%)

310 VDU29,0;0;

320 GCOL0,0

330 MOVEX%,Y%

340 MOVE300,0:PLOT85,0,0

350 GCOL0,7:MOVE150,0:DRAWX%,Y%

360 ENDPROC

PROCSKY

This simply fills the region above the line y=Y% in the logical colour 6. This is pale blue with the default palette settings. The sky is drawn using two triangle fill commands.

370 DEFPROCSKY(Y%)

380 GCOL0,6

390 MOVE0,Y%:MOVE0,1200:PLOT85,1300,1200

400 MOVE1300,Y%:PLOT85,0,Y%

410 ENDPROC

Desert Island

This program draws a view of a desert island with palm trees on it. The program is quite long but is divided up into fairly simple procedures that each draw a part of the picture. Once the entire picture has been drawn the sea springs to life as waves go dancing across it. Because of the modular nature of the program it should not be too hard to get each section to work before joining them together to draw the entire picture.

ISLAND

0 REM Island

20 MODE2

30 VDU5

40 PROCSEA(650)

50 PROCISLE(700,400,250)

60 PROCPALM(700,500,300)

70 PROCPALM(800,450,300)

80 REPEAT

90 PROCSURF

100 UNTIL FALSE

110 END

The main program simply calls the various procedures one by one. All that follows are the procedure declarations that go into the details of how to draw these objects.

PROCSEA

The sea is composed of a series of sine waves drawn next to each other. To speed up the drawing a table of sine values is stored in the array S. The waves are drawn using 8 different logical colours, and this is exploited later in PROCSURF to give the impression of motion. The horizon is at the line y=650; above this PROCSEA fills in the sky which grows out of the sea.

120 DEFPROCSEA(YL%)

130 DIM S(100)

140 FORI%=8TO15:VDU19,I%,4;0;:NEXT

150 FORI%=0TO100:S(I%)=SIN(I%):NEXT

160 FORY%=0 TO YL% STEP 12

170 VDU29,0;Y%;

180 S%=8+RND(10):MOVE0,S%*S(Y% MOD 100)

190 C%=7+RND(8)

200 FORX%=0 TO 1279 STEP 24

210 GCOL0,C%:C%=C%+1:IF C%=16 THEN C%=8

220 DRAW X%,S%*S((X%+Y%) MOD 100)

230 NEXT,

240 YL%=Y%:S%=8

250 VDU29,0;YL%;

260 MOVE0,S%*S(YL% MOD 100)

270 FORX%=0 TO 1279 STEP 24

280 NY%=S%*S((X%+24+YL%) MOD 100)

290 GCOL0,6:Y%=S%*S((X%+YL%)MOD 100)

300 MOVE X%,1200:PLOT 85,X%+24,1200:

MOVE X%+24,NY%:PLOT85,X%,Y%

310 GCOL0,C%:C%=C%+1:IF C%=16 THEN C%=8

320 DRAWX%+24,NY%

330 NEXT

340 ENDPROC

Description of PROCSEA

150	Define logical colours 8-15 to appear as dark blue.
160	Save sine values in the array S.
170	Draw lines of waves up to the horizon.
180	Put the origin at the start of the line.
190	S% is a slightly random amplitude. Move to the start of the wave.
200	Select a random logical colour to start.
210	Move across drawing the wave.
220	Select a new colour for each part of the wave
230	Draw the wave.
240	On leaving these loops all that remains is to fill in the sky, and draw one more wave along the horizon.
250	Fudge the horizon to be above the last wave drawn. Make the amplitude 8.
260	Put the origin at the start of the horizon wave .
270	Move to the start of the horizon wave.
280	Now move along the horizon.
290	NY% is the next Y value on the horizon wave.
300	Select logical colour 6 for the sky, and calculate the current Y value,
310	Fill in the rectangle of sky above the next step along the horizon wave. The aim of all this business is to get the sky and sea to knit together.
320	Select the colour of the next segment of the horizon wave.
330	Draw that part of the wave.

PROCISLE

The island has the outline of a slightly squashed oval. The first two parameters give the position of the island, and the third specifies its size. There are two stages in drawing the island: first, the outline is drawn and the whole next, curved lines are drawn give an impression of depth.

350 DEFPROCISLE(XO%,YO%,S%)

360 GCOL0,3

370 VDU29,XO%;YO%;:MOVE0,0

380 FORA=0 TO 2*PI+0.2 STEP 0.2

390 X%=S%*SIN(A):Y%=COS(A)*S%

400 IF Y%>0 THEN Y%=Y%/2 ELSE Y%=Y%/3

410 MOVE0,0:PLOT85,X%,Y%

420 NEXT

430 GCOL0,2

440 FORA=PI/2 TO PI STEP 0.05

450 S1%=S%*SIN(A)

460 VDU29,XO%;YO%+COS(A)*S%/3;

470 MOVE-S1%,0

480 FORB=-PI/2 TO PI/2+0.2 STEP 0.2

490 X%=S1%*SIN(B):Y%=COS(B)*S1%/2

500 DRAWX%,Y%

510 NEXT,

520 ENDPROC

Description of PROCISLE

370	The colour of the sand.
390	This loop traces the outline of the island in colour.
400	The point (X%,Y%) moves around a circle.
410	Squash this circle.
420	Fill in a segment.
440	The colour of the grass
450	We draw a curved line each time around this loop.
460	S1% is the X-coordinate of a point on the edge of the island.
470	This moves the origin and specifies the vertical displacement of each curved line.
480-510	Draw a curved line.

PROCPALM

This draws a palm tree of size S% with its base at (X%,Y%). The palm is composed of two parts: the trunk and the leaves. The curved trunk of the tree is formed by filling the region between portions of two circles, one slightly larger than the other. The leaves are filled using a random walk along radial lines of a circle whose centre is at the top of the trunk.

530 DEFPROCPALM(X%,Y%,S%)

540 VDU29,X%-S%;Y%;:MOVES%,0

550 S1%=1.1*S%

560 ST=40/S%

570 FORA=0TO PI/3 STEP ST

580 GCOL0,1

590 SI=SIN(A):CO=COS(A)

600 MOVES%*CO,S%*SI:MOVES1%*CO,S1%*SI

610 PLOT85,S1%*COS(A+2*ST),S1%*SIN(A+2*ST)

620 MOVES%*COS(A+ST),S%*SIN(A+ST):PLOT85,S%*CO,S%*SI

630 GCOL0,7:DRAWS1%*CO,S1%*SI

640 NEXT

650 VDU29,X%+S%*(COS(PI/3)-1);Y%+S%*SIN

(PI/3)+0.05*S%;

660 GCOL0,2:MOVE0,0:MOVE0,4

670 FORA=0 TO 2*PI STEP 0.8

680 FORI%=0TOS% STEP 16

690 IF RND(2)-1 THEN GCOL0,0 ELSE GCOL0,2

700 X%=I%/2*SIN(A)+RND(I%/4)-I%/8

710 Y%=I%/3*COS(A)+RND(I%/4)-I%/8

720 PLOT85,X%,Y%

730 NEXT I%,A

740 ENDPROC

Description of PROCPALM

550	S% gives the radius of the inner circle used to draw the trunk.
560	Sl% will be the radius of the outer circle.
570	ST% is the angular step size; this determines the number of segments in the trunk.
580-650	Move round the circle filling the segments in logical colour I (red) and drawing lines between them in logical colour 7 (white).
660	Put the origin at the top of the trunk.
670	Move roughly to the centre of the leaf circle.
680	Go all the way round the circle.
690	I% moves out to give radial lines.
700	Either draw in green or black.
710-720	Introduce some randomness.
730	Fill that part of the leaf.

PROCSURF

This procedure redefines the physical colours that correspond to the logical colours numbered 8-15. Two effects are produced: first, an impression of ripples moving across the waves, and secondly, the impression of more substantial waves.

In the first case only one of the 8 logical colours is changed at one time. To produce more surf the next section introduces a gap between the two 'points' at which the palette changes occur. The groundwork for this procedure has been done in PROCSEA where the multicoloured sea is drawn. There is enormous scope for further effects to be produced.

750 DEF PROCSURF

760 C%=8

770 FORI%=0TO100

780 VDU19,C%,7;0;

790 A=INKEY(12)

800 VDU19,C%,4;0;

810 C%=C%+1:IF C%=16 THEN C%=8

820 NEXT

830 FORJ%=1TO100

840 R%=RND(5)

850 FORK%=0TO20

860 C%=C%+1:IF C%=16 THEN C%=8

870 VDU19,C%,4;0;

880 VDU19,(C%+R%)MOD 8 +8;0;

890 A=INKEY(12)

900 NEXT K%,J%

910 ENDPROC

Description of PROCSURF

770	C% gives the logical colour to be changed.
780	While in this loop simple ripples are produced.
790	Make logical colour C% appear white.
800	Wait 12 centi-seconds.
810	Make log1cal colour C% appear dark blue again.
820	Increase C%; this causes the ripple to move to the right.
840	While in this loop more complicated waves appear.
850	The value of R% determines how large the area of white surf will become.
860	Do 20 surf movements before changing R%.
880	Make logical colour C% appear as dark blue.
890	The effect of this is to make a gap between where the wave becomes white and the point at which it reverts to being blue. This means that instead of a small dash, a portion of the wave appears in white.


Next     Top