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:
CLS SCREEN 2 PRINT "Hi!" ENDNow for the explanatory thing:
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!")
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$ + "!" ENDTo 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
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
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
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
Printing to a printer is as easy as printing to a screen. Instead of PRINT use LPRINT.
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!