C64 Users Guide

From Maze

Revision as of 12:29, 26 May 2010 by Nickm (Talk | contribs) (New page: Image:C64 Users Guide 53.png == Variant in a later edition of the C64 User's Manual == From [http://www.unusedino.de/ec64/technical/project64/users_guide2.html The Project 64 etext...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


C64_Users_Guide_53.png
853 × 1324 pixels

Variant in a later edition of the C64 User's Manual

From The Project 64 etext of the ~Commodore 64 MicroComputer User Manual (2d ed)~

Copyright (C) 1984 by Commodore Business Machines, (UK) Ltd.

Converted to etext by Frank Jeno Kontros <jeno@kontr.uzhgorod.ua>

C64UG210.TXT, June 1997, etext #251#

Note that the line number of the last line has changed from "40" to "20."

5.8. RANDOM GRAPHICS

  As  a final note on random numbers, and as an introduction to designing
graphics, try entering and RUNning this program:

  10 PRINT "(SHIFT-CLR/HOME)"
  20 PRINT CHR$(205.5 + RND(1));
  30 GOTO 20

  The  function CHR$ (CHaracter String) gives you a character, based on a
standard  code number from 0 to 255.  Every character the 64 can print is
encoded this way. Appendix F lists the CHR$ codes for all keys.
  A  quick  way  of  finding out the code for any character is to use the
function ASC (for the standard ASCII code). Type:

  PRINT ASC("X")

X  is  the  character  you're checking. X can be any printable character,
including   graphics  characters.  You  must  enclose  the  character  in
quotation marks. Here's an example:

  PRINT ASC("G")
  71

The CHR$ function is the opposite of ASC.

  PRINT CHR$(71)
  G

If you type:

  PRINT CHR$(205);CHR$(206)

the  computer  displays  the two right side graphics on the M and N keys,
which are the characters used in the little maze program you just tried.
  The  formula  205.5 + RND(1) tells the computer to pick a random number
between  205.5  and  206.5.  There  is fifty-fifty chance that the random
number  will  be  above  or below 206. CHR$ ignores fractional values, so
half the time the character with code 205 is printed, and the rest of the
time code 206 is displayed.
  You  can experiment with this program by adding or subtracting a couple
of  tenths  from  205.5.  This gives either character a greater chance of
being displayed.
Personal tools