How to Write Game Programs in QBasic

Written by darrin koltow

Share

Tweet

Share

Pin

Email

Giving clear names to all variables makes debugging QBasic games easier. (binary world image by Attila Toro from Fotolia.com)

QBasic is a programming language developed by Microsoft. It's based closely on the BASIC language, whose letters stand for Beginners All Purpose Symbolic Instruction Code. QBasic can make many different types of programs, including video games. A key step in making such games from scratch is designing the game, which means writing in detail how you want the game to work. Personal satisfaction is one benefit you get from making QBasic games. Another is increased programming skill, which you can apply to other programming projects, including those in other languages.

Skill level:

Easy

Other People Are Reading

Instructions

1

Download a QBasic game, such as the Space Battles game on Pete's QBasic site, Jack's 3-D Game from the same site or Moonbugs from the QBasic Station site (see Resources).

2

Read the game's program listing, including all comments. If you understand what a statement without a comment means, write your own comment. For example, you may read the statement "flagGameOver = true" and write, "This statement is indicating that the game is over." Once you can write a comment explaining each line of the program listing, you'll understand the game well enough to turn it into your own game.

3

Execute the game one statement at a time, using your development environment's debugging tools. Read your environment's documentation for details on code stepping, which is how programmers refer to executing one statement at a time.

4

Write on paper, as you're stepping through the game, the value of each variable as it changes. For example, you may write "The variable 'PlayerPoints' held '1' before I answered the trivia question correctly. It now holds '10'."

5

Write, in the program listing, new comments that reflect your increased understanding of the game. For example, after observing the hypothetical "PlayerPoints" variable in the previous step, you may write "'PlayerPoints' holds my score, which is based on correct answers to the game's questions."

6

Repeat Steps 3 through 5 until you've written a comment for each statement in the game's source listing. You can now make modifications to the game.

7

Write on paper a list of changes you'd like to make to the original game. One change might be, "The option for changing the turret's angle should be on the 'gunner' screen, not the 'ship commander' screen." Be as specific as you can in describing each change, as this makes programming easier.

8

Write the QBasic source code that implements the list items from the previous step.

9

Test and debug the game using your development environment's debugging tools.