Download QBasic_Learn
Transcript
www.omideiran.net www.ircdvd.com www.irebooks.com www. irtanin.com SCREEN 12 CLS CIRCLE (320, 240), 100, 15 PAINT (320, 240), 15, 15 PAINT fills an area with a color. It stops painting when it runs into a certain color on the screen. The coordinate (320, 240) tells PAINT where to start filling in, and the first "15" tells PAINT to use bright white as the paint color. The second "15" tells PAINT to stop painting when it runs into anything that is bright white. Circle Art Concentric circles are very easy to draw: SCREEN 12 CLS FOR I = 5 TO 200 STEP 5 CIRCLE (320, 240), I, 15 NEXT I With CIRCLE, PAINT and some random numbers, we can make some interesting pictures: SCREEN 12 CLS FOR I = 1 TO 50 X = INT(RND * 640) Y = INT(RND * 480) R = INT(RND * 100) Color1 = INT(RND * 16) CIRCLE (X, Y), R, Color1 PAINT (X, Y), Color1, Color1 NEXT I Chapter 22 - INKEY$ Up to now, we've been using INPUT to get things from the keyboard. The problem with INPUT is that our program stops until the user presses the enter key. Wouldn't it be nice to keep the program running and still be able to get input from the keyboard? INKEY$ will let you do this. Using INKEY$ is very important if you want to make "real-time" game programs. Let's fix the clock program to let the user press any key to stop the program. This way the user doesn't have to know about the Break key. CLS LOCATE 3, 1 PRINT "Press any key to exit" DO LOCATE 1, 1 PRINT TIME$ SLEEP 1 LOOP WHILE INKEY$ = "" Not bad at all. Now we don't need to teach the user about the Break key. We can do the same thing in any of our other programs that need the Break key. If the user does not press a key, INKEY$ returns nothing or "". #*