How to Program 3D Games in QBasic

Written by darrin koltow

Share

Tweet

Share

Pin

Email

Writing libraries of QBasic 3-D functions makes coding your second game easier. (binary world image by Attila Toro from Fotolia.com)

QBasic is a programming language made by Microsoft, and is based closely on the BASIC language. QBasic can produce many types of programs, including 3-D games. On step needed to program QBasic 3-D games is to call graphics routines that perform the basic 3-D transformations of movement, rotation and scaling on objects. An optional step is transforming the camera, which is the viewpoint through which the game's player sees the 3-D scene. You can use the 3-D programming skills you learn by making a 3-D QBasic game to make other graphics-intensive programs, like computer aided design applications.

Skill level:

Moderate

Other People Are Reading

Things you need

QBasic

Show MoreHide

Instructions

1

Download an open source 3-D game written in another language. Example 3-D programs include Rigs of Rods and Cube 2. Studying an open source 3-D QBasic game would entail less work. However, few such programs exist.

2

Make printouts of all source files in the game, then manually trace through the program from its starting function to its end. Tracing through a program means to write down all variables you encounter and their values as they change from statement to statement. To help you learn how to step through a program, use a debugger for the language the game was written in. C++ debuggers are available from Open Wacom and Microsoft Visual C++ Express. Repeat this step a minimum of ten times. Completing this step will teach you how the game works, which you'll need to know before translating the game to QBasic.

3

Write the QBasic equivalent for each statement in the game's source. For example, the QBasic "REM" statement is the equivalent of the C++ comment syntax "//". And the "Do While...Loop" structure in QBasic is equivalent to the Java and C++ loop structure "for (i=0;i<n; i++) { /statements/.".

To learn other QBasic equivalents for statements in other languages, read the syntax specification for QBasic in the documentation that came with your QBasic editor. Read also the syntax specification for the game's original language. The Java language specification is on Sun's "Java Language Specification" page. You can read The C++ language specification on the home page of David Adams, a manager with the federal subatomic particle project ATLAS.

4

Run the finished QBasic translation of the original game, and fix any errors in it using your editor's debugging tools

5

Make small changes to the game, such as changing string and numeric constants.

6

Write the code for effecting larger changes, such as the appearance or behaviour of characters and obstacles.