EduGateway(TM) "Bubbles" Program


Here's a simple and fun program to demonstrate QBASIC programming:
        Note: This program is easier to view if you turn off hypertext (shortcut) underlining.
SCREEN 9

DIM x AS INTEGER, y AS INTEGER, r AS INTEGER

DO

  x = RND * 720

  y = (RND * 100) + 200

  r = (RND * 20) + 10

  CIRCLE (x, y), r, , , , .8

  PRINT ""

LOOP


You can use your web browser to copy this program to the clipboard (Click and Drag to Select, then Copy). Then paste it into any text editor (like Windows Notepad), and save it in a file called "bubbles.bas". Then use DOS QBASIC to open the file and run it. The program should work with almost any graphics adapter by changing the "SCREEN 9" statement to use a different screen number. Hercules graphics adapters, for example, should use "SCREEN 3" for proper operation.

This fun little program exploits a quirk in PC graphics adapters to create a simple animation effect. Because PCs were originally text machines, they supported a simple scrolling text display. Then when graphics were added, they needed to retain that scrolling capability for downward compatibility. The result is a graphics display that can quickly scroll upward one character height at a time. This scrolling is very fast even on the original XT class machines. Try it and see for yourself!

After you've run the program, try making various changes. First try making the "bubbles" larger or smaller (hint: the "r" stands for "radius"). Then try changing the "bubbles" to other shapes. Use the "LINE" statement, for example, to draw snowflakes instead of bubbles (hint: replace the "CIRCLE" statement with three or four "LINE" statements).


© 1997-2000 EduGateway(TM)