QBASIC


Welcome to the world of real programming! No longer are you stuck with using the internet for your games.
In addition QBASIC is the start of a whole series of languages. The 'Q' stands for Quick.
What the BASIC stands for is not so basic! It means: 'Beginners All Purpose Symbolic Instruction Code'. Basic is truly basic though!
I know you won't believe me after telling you what it stood for; but remember the 'Beginners' part! On to the lessons:




The Qbasic Shell:

This here's the QBASIC shell! (I'll explain it later)
CLS
SCREEN 2
PRINT "Hi!"
END
Now for the explanatory thing:
The CLS statement (A command that you tell the computer) clears the screen.
SCREEN 2 makes it look ultra-fancy.
The PRINT statement I'll tell you about later.
The END statement closes the program and takes you back to the QBASIC editor.

NOTE: There is another closing statement called SYSTEM; which closes the program and the editor.



Text

Remember the PRINT statement from before? That actually puts text on the screen; not the printer.
Print is incredibly basic. The attributes you used in XHTML are similar.
You just type the command then what you want it to pop up with in quotes ("). (e.g. PRINT "Howdy!")



Input and Variables

First you'll learn about variables. If you've used Algebra you'll most likely know what a variable is.
There are two main types of variables; String and Integer. An Integer is an in integer between... I forget, but it's large range! :-/
A string is a string of characters (or letters, numbers, and whatever) strung out in a row. (e.g. "The fat cat sat on the rat.")
All string variable names end with a $ sign. All integers a just plain old names.

Now for input:
The INPUT function puts a value from the user into a variable. To see a program with input and variables in action look below:

CLS
SCREEN 2
PRINT "What is your name?"
INPUT name$
PRINT "Hi," + name$ + "!"
END
To do math with integers use this type of code:
CLS
SCREEN 2
PRINT "Enter number one:"
INPUT numone
PRINT "Enter number two:"
INPUT numtwo
PRINT numone + numtwo
END

IF Statements

Ever thought; "If he does this I'll do that."? I'm sure you have at some point. Computers can do that to with from their ever-clever programmer.
Use the IF statement to do this with a computer. You'll need a basic knowledge of variables to use the IF statement.
The IF statement takes the following syntax (I'll explain it later):

CLS
SCREEN 2
PRINT "Do you want to play again? (Y/N)"
INPUT playagain$
IF playagain$ = "y" THEN
PRINT "Great!"
ELSE
PRINT "Bye!"
END
END IF
END

Now for the explanation:
First you'll notice I took in the variable playagain$. Then I used the IF statement to match it to a letter (in this case "y").
Whenever you're matching it to an integer or variable value; DON'T use quotes. Otherwise you MUST use quotes. You can compare variables
to other variables. Here's an example:
CLS
SCREEN 2
PRINT "What is the first persons last name?"
INPUT firstperson$
PRINT "What is the second persons last name?"
INPUT secondperson$
IF firstperson$ = secondperson$ THEN
PRINT "You're related!"
ELSE
PRINT "WOW! You're not related (most likely)."
END IF
END

This is a very simple example. DO NOT forget to close the IF statement with an END IF!

Sound

Sound, as always is the icing on the cake, and QBASIC is no exception. You can't play .wav files or any other file, but QBASIC has built in sounds.
The SOUND statement plays a sound (I think). SOUND takes an integer value between 0 and 30,000 and plays it through the internal speakers.
Sound takes the following format:

CLS
SCREEN 2
PRINT "Playing sound..."
SOUND 1000, 4
END

You can also do a plain old beep. Just use the BEEP statement. No other values are needed.

NOTE: sounds in the very low range can't be heard by the human ear. Please don't have a dog around if you're going to play sounds like that! The number after the large one is the length of the sound.

Printing

Printing to a printer is as easy as printing to a screen. Instead of PRINT use LPRINT.

Strategy

QBASIC games can be fun. Most the keys are, once again, in the Intro. Don't forget to make your games 'Interesting and Engaging'.
The best types of QBASIC games are text adventure games.
If you get awesome at QBASIC you can make other types. Just remember to have fun making the game!