
QBasic is a basic programming language that can be used for a variety of tasks, such as creating games. As a "high-level" language, QBasic is more limited than other prominent programming languages such as C+ because it relies more on human language than machine code. Getting to know QBasic's basic commands is the best way to go about writing your own games in the language.
Instructions
1
Open QBasic. Type "PRINT 'Hello World'." On the second line type "PRINT 5." On the third line enter "PRINT 5 + 3." Hit "Run" or "F5" to sample your first program.
2
Type the command "END" to end a program.
3
Enter "INPUT" followed by the name of what you want to input, called an "ARRAY." The array deals with numbers or words. Words always ends with a "$" sign but numbers do not. For example: "INPUT name$" and "INPUT number."
4
Use the PRINT and INPUT commands together. For instance:
"PRINT 'Wake up!'"
"INPUT Johnny$"
"PRINT 'Leave me alone.'"
5
Use the "IF" and "END IF" commands. To do this, enter something along the lines of the following:
"INPUT name$"
"IF name$ = 'Johnny' THEN"
"PRINT 'Hello, Johnny!'"
"END IF"
This program tells the game to ask the user his name. If his name is Johnny, the computer will print "Hello, Johnny!" Without the "END IF" command, the game will continue to print "Hello, Johnny!" each time the user inputs his name.
6
Create loops by using the "FOR" and "NEXT" commands. For example:
"FOR i = 1 to 10"
"PRINT 'Yes'"
"NEXT i"
This command tells the game to repeat the printed command from one location (i) to a second location (i).
7
Use all the commands together to build a basic game in QBasic.
No comments:
Post a Comment