| Original Message |
Anonymous (no login) Posted Apr 1, 2012 3:58 AM
is ainternetcade and the charakter...install starwars old republik think there was enough pain and stars...
better that
Strings meanwhile are text, so you would use it only really with PRINT. For example:
Name$ = 'Adam'
PRINT 'Hello'; name$; '!'
This then prints 'Hello Adam!' on the screen, but notice how the name$ is outside of the quotation marks (with semi colons) to avoid confusion. You can also get the user to input a string…
PRINT 'Hi, what's your name please?'
INPUT name$
PRINT 'Hi'; name$; '!'
This then asks for the user's name, then brings up a cursor, saying hi to that person after they press enter. This is one form of input and this is how the user interacts with the variables on the screen to make the programmes interactive. They can also interact in real time in order to change variables like so:
10
PSET (20, 10),4
SELECT CASE INKEY$
CASE 'P'
X = x + 1
CLS
CASE 'O'
X = x - 1
CASE 'E'
STOP
CLS
END SELECT
GOTO 10
Here 'SELECT CASE INKEY$' tells it to expect input, while the following parts mean if the input is 'P' then X = X + 1 and the pset moves to the right, if they press 'O' however then it moves to the left. Everything beneath the 'CASE 'E'' is what happens if you press 'E' until the next 'CASE' or the 'END SELECT'.
IF, AND, OR, ELSE and THEN
Finally this is where things get interesting and you can create interesting sequences of events. The 'IF, AND and THEN' commands all do precisely what you would expect them to in English, but are then followed by commands or maths.
For example:
PRINT 'What is your name?'
INPUT name$
IF name$ = 'Adam' THEN PRINT 'My name is Adam too!'
ELSE PRINT 'Hi'; name$; ', nice to meet you!'
Alternatively you could use it to make games. Here is a very simple game:
X = 1
10
PSET (20, 10), 6
PSET (x, 10), 2
SELECT CASE INKEY$
CASE 'P'
X = x + 1
CLS
CASE 'O'
X = x - 1
CLS
CASE 'E'
STOP
END SELECT
IF x = 20 THEN GOTO out
GOTO 10
Out:
CLS
PRINT 'Well done you reached the gold!'
SLEEP 0
STOP
Here you have a green dot, you press 'P' to move it right across the screen, and when it reaches the red dot (20 along) it tells you well done and exits on a key press.
Of course all this is really just a very basic introduction to QBASIC and does not really touch on the huge number of things you can do with it. However with just these few tools, it is possible to make a vast range of different programmes and games, and to start learning extra code on top to give them even more uses.
|
|
|