Adding color in Basic is something that is easily done and adds a great deal of fun and excitement. The usually drab white and black is quite distasteful.
Adding color is as simple as the color command. The command is COLOR. COLOR is simply added to
a line with the specified color after it.
10 COLOR 2
20 PRINT "This text would be printed green"
The COLOR command changes the color of the output. There are 32 colors in basic ranging from 0 to 31. The primary colors and their derivitives range from 0 to 15 and after that the colors have speacial effects like flashing and background changes.
The following is a color chart:
0 BlackSound can also be added in some versions of basic and played right through the computer. (This is not to be confused with sound from a sound board like SoundBlaster, which comes in a much, much later lesson) The way of adding simple sound is the PLAY command. PLAY is used by simply adding it to a line followed by the notes that are desired in quotation marks.
10 PLAY "AB"Play uses only the notes A, B, C, D, E, F, and G. They all come from the same octave and do not use flats, sharps, or skip beats. However, it is fun to add sound, and some very simple tunes can be replicated. Also, sound cues can be added that indicate menu choices or errors.
10 PLAY "DE"Play around with the PLAY command, and simple combinations can often create a most desired effect. Also, the default command BEEP can be used in a line of code. Be warned this command draws from the Windows default beep even though Basic is a Dos based program and may not always be deired.
10 BEEPIt is recomended that BEEP or PLAY not be used in any loops (as discussed in later lessons) because the sound is easily annoying. On this same note, adding sound is nice, but if over done it creates a most undesired effect.
Try adding some sound(s) to a program you already have written, and change around the color of your text.
QBasic Homeianmacallen.com | Annex | Archive
All content Copyright 2006 Ian MacAllen Unless otherwise Atrributed.
Contact:
ianmac47@hotmail.com