An "interface" is a system that causes some sort of communication between a user and a machine. Interfacing can range from being very easy to accomplish, such as in the case of simply asking the user for a number, to very difficult to accomplish, such as tracking all key presses. A good gaming interface is timed so that the program doesn't somehow "miss" a key press.
There are several commands that can be used to create a rock-solid gaming interface. These commands are Input
, Prompt
, and getKey
. The first two are used to receive and store data that the user inputs. The last is used to monitor key presses. The next section will discuss data storage techniques. This section will discuss the above three commands.
Input
This command asks a user for data, with the prompt accompanied by a single-line string of text that explains to the user what to input. The accompanying text is limited to one line, which may be a problem as it is not easy to explain complicated things to a user within that space. There are ways to work around this, which will be explained later.
Prompt
Prompt
functions in a manner similar to Input
, except that Prompt
will only display the name of the variable being asked for. This makes it even less explanatory than Input, but it is possible to work around this as well.
GetKey
This is perhaps the most important gaming command in the entire programming language. getKey
simply returns the numerical value of the last key pressed. For games in which a player needs to attack, defend, or perform multiple tasks within a short period of time, getKey quickly becomes one of the most frequently used commands within the program.
For a guide to keys and their corresponding getKey
values, see the Wikipad.
Now let's discuss ways to work around limitations of Input
and Prompt
. Remember that the Disp
command writes a line of text to the current line, then moves the cursor to the next line. Remember also that the Input
command places its one-line prompt on whatever line the cursor is on. Therefore, by using the Disp
command, you can write out the first few lines of text you wish to prompt, then place the last line in the Input
command. Or you could forgo the one-line explanation altogether and use only Disp
for the prompt. Both examples are shown below and will produce a similar result when run.
Example 1 | Example 2 |
---|---|
:Disp "PLEASE INPUT","YOUR X AND Y" :Input "COORDINATES: ",Str0 |
:Disp "PLEASE INPUT","YOUR X AND Y","COORDINATES:" :Input "",Str0 |