QuickBasic Toys and Games

I created many of these simple but colorful programs with Tom Godar and other high-school students while teaching them to program in their spare time, in Monteverde, Costa Rica.  At the bottom of the page, you can download and run them yourself, or even experiment with changes to the programs if you like.

previous     up

Origami.bas produces a lovely, frenetically changing animation.  It is a variation of a popular screen-saver, with rectangles instead of lines, whose sides reflect from the egdes of the screen.
 

Clouds.bas (below) produces pretty patterns using a random walk, with horizontal variance somwhat larger than vertical.
 

This is one of numerous 3-D stereograms we created.  They involved the geometry of depth perception, in varying the spacing of pattern repetition.  Some more involved examples also used 3-D rotation matrices and convergence to the surface point in the foreground along the line of sight.  This example (3DSaddle.bas) shows a gracefully curved surface, z=Sin(x*y).  You should be able to perceive the 3-dimensional image in the pattern below if your screen is not too small, and you're good at that sort of thing....
 

These programs provided new learners with lots of colorful action for the amount of programmimg needed.  Below is the entire quick-and-dirty code for one of the simpler 3-D stereogram programs, 3DPlanes.bas.
 

   XT = 640: yt = 480: SCR = 12: NC = 15: XS1 = 100: XD = 12
   YS = 2: XS = 12
   SCREEN SCR: CLS : RANDOMIZE TIMER: KEY OFF
   XP = XT / XS: YP = yt / YS: XS2 = XS1 - XD: T = 0
  
   FOR I = 1 TO 150
    CIRCLE (RND * XS1, RND * yt), RND * XS1, RND * NC + 1
    NEXT
  
   DIM A(1000)
   FOR Y = 0 TO yt - YS STEP YS
    yy = Y: IF yy >= yt / 2 THEN yy = yt - 1 - Y
    Y2 = INT((yy + 36) / 2)
    FOR X = Y2 TO XT - XS STEP XS
     XG = X - Y2: IF XG < 0 GOTO 20
     GET (XG, Y)-(XG + XS - 1, Y + YS - 1), A
     PUT (X, Y), A, PSET
20   NEXT X
    NEXT Y

22 IF INKEY$ = "" GOTO 22
  
   SCREEN 2: SCREEN 0, 0, 0
   SYSTEM

The video game below (Crash) was the most ambitious program, and inspired some other game programming (which kids want to learn more than any other type of programming, it seems...).  It involved an event loop to process keystrokes asynchronously, while keeping sounds and graphics up-to-date in real time.  The game-playing heuristics of a robot player for the 1-player option also had to be programmed.

The best student-hobbyist (Tom Godar) created a help screen for this program.  Unfortunately, the downloadable version doesn't contain that help screen, but it's very easy to learn anyway.  You use the arrow keys to leave a trail of  blocks, and avoid running into yours or opponent's blocks.  Hit escape to exit.  That's all you really need to know.

The Return key allows you to toggle options for sound and for 1 or 2 players.  The x, c, v and space keys serve as arrow keys for player 2.  The 0 key resets the score.

The kids liked to dig into the parameters at the top of the program to change the size of the blocks or to crank up the speed to an hysterical pace.
 

Below are a couple more fun-to-watch abstract animations based on random walks: City and Drunk.  Simple parameters for drift, variance, shape, color, etc. can be changed in the program to produce very different displays.  Students enjoyed doing their own experiments, learning how to create parameters and what the parameters mean.
 

I was sorry to see QBasic, which was included with DOS, disappear completely when Windows came out.  It had evolved  into a very nice interpreted system for first-time programmers.  Complete novices could learn the elements of programming very quickly, and create lively color animations with just a few uncomplicated statements.  QBasic included enough structured constructs to eliminate most of the statement numbers which plague older Basic versions, and it could accommodate fairly large projects.  The students quickly learned, in a hands-on way, realtions between algebra and programming, for example, or between cartesian coordinates and positions of graphic objects on the screen.

Download these toys and try them yourself (Windows only).

qbtoys.exe  This is a self-extracting archive (339kb).

Create an empty scratch directory, then click the link above and save the file into that directory.  Double-clicking the file after it downloads will unpack its contents into the scratch directory.  Then double-click any of the "MS-DOS Shortcut" (.pif) files to run the corresponding program.  Hit any key to exit a program (the Crash game requires the escape key to exit).  Try origami, 3DSaddle, Trk7, Clouds, City, and Crash, for starters.  There are 33 small programs in all.

You can click the .bat files instead, but then you have to close the program's window yourself on exit.  Do not click the .bas program files directly; they must be interpreted by QBasic.

If you already have QBasic lying around somewhere (as well as WinZip, or another program to decompress .zip files) you can just download the programs:  qbtoys.zip (just 37kb).  Download and unzip the file into a scratch directory, put your own qbasic.exe and qbasic.hlp in that directory or somewhere on your program search path, and again click on the shortcut files to run the programs.

If you double-click on qbasic.exe, to run it directly, you can then manually open, run, view, and twiddle the programs, or create your own.  Have fun.

previous     up