EasyManua.ls Logo

AMSTRAD CPC464 - Page 110

AMSTRAD CPC464
249 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...
The PLOT statement in line 100 is the part of the program that draws the line. It produces one dot
(pixel) on the screen for each calculation it makes in the FOR NEXT loop (lines 80-l 10) - and the
result is displayed on your screen.
The CPC464 has many simple and powerful commands - you can add to the effect of the above
progam by simply adding:
15 BORDER 6,9
RUN again. The border is now alternating between the colour numbers 6 and 9. The flashing rate is
set by the default values. To make the program loop continuously until you press [ESC]ape (twice to
break out of the program, once to suspend operation), add:
120 GOTO 50
See that the flashing border did not stop when the program did - this is because the border is
controlled indepedently of the rest of the program. To stop the flashing and set the border to bright
blue, press [ESC] twice, then change line 15 to
15 BORDER 2
RUN the program, and the flashing stops.
To change the colour of the curve and the background, you must change the colour of the INK in
lines 30 and 40. When you LIST the program, it should then look like:
10 REM DRAW SINE WAVE
15 BORDER 2
20 MODE 2
30 INK 1,2
40 INK 0,20
50 CLS
60 DEG
70 ORIGIN 0,200
80 FOR n=0 TO 720
90 y=SIN(n)
100 PLOT n*640/720,198*y,l
110 NEXT
120 GOT0 50
The number 1 at the end of the PLOT statement in line 100 tells the computer to plot the curve in
the colour specified by the INK 1 command in line 30. Check the definition of the PLOT statement in
the keyword listing of Chapter 8 and you will see exactly how the various parts of this statement
work.
If you look closely at the curve being plotted on the screen, you will see that it is not a continuous
line, but is broken in many fine segments. The smallest individual segment is an example of a pixel
described earlier.

Table of Contents

Other manuals for AMSTRAD CPC464

Related product manuals