~ubuntu-branches/ubuntu/vivid/inform/vivid

« back to all changes in this revision

Viewing changes to html/section32.html

  • Committer: Bazaar Package Importer
  • Author(s): Jan Christoph Nordholz
  • Date: 2008-05-26 22:09:44 UTC
  • mfrom: (2.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080526220944-ba7phz0d1k4vo7wx
Tags: 6.31.1+dfsg-1
* Remove a considerable number of files from the package
  due to unacceptable licensing terms.
* Repair library symlinks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<HTML><HEAD><TITLE>Section 32: Boxes, menus and drawings</TITLE></HEAD>
2
 
<BODY BGCOLOR="#FFFFFF">
3
 
<TABLE><P>
4
 
<TR><TD Valign="top"><A HREF="contents.html">Contents</A><BR><A HREF="section31.html">Back</A><BR><A HREF="section33.html">Forward</A><TD bgcolor="#F5DEB3"><BLOCKQUOTE><H3>32. Boxes, menus and drawings</H3></BLOCKQUOTE><TR><TD><TD>
5
 
<P>
6
 
 
7
 
<BLOCKQUOTE>
8
 
Yes, all right, I won't do the menu... I don't think you realise
9
 
how long it takes to do the menu, but no, it doesn't matter, I'll
10
 
hang the picture now.  If the menus are late for lunch it doesn't
11
 
matter, the guests can all come and look at the picture till they
12
 
are ready, right?
13
 
<P>...John Cleese and Connie Booth, <I>Fawlty Towers</I></BLOCKQUOTE>
14
 
<P>
15
 
 
16
 
<P>
17
 
One harmless effect, though not very special, is to ask the player
18
 
a yes/no question.  To do this, print up the question and then
19
 
call the library routine <TT>YesOrNo</TT>, which returns true/false
20
 
accordingly.
21
 
<P>
22
 
 
23
 
The status line is perhaps the most distinctive feature of Infocom games in
24
 
play.  This is the (usually highlighted) bar across the top of the screen. 
25
 
Usually, the game automatically prints the current game location, and either
26
 
the time or the score and number of turns taken.  It has the score/turns
27
 
format unless the directive
28
 
<PRE>
29
 
Statusline time;
30
 
</PRE>
31
 
 
32
 
has been written in the program, in which case the game's 24-hour clock is
33
 
displayed.
34
 
<P>
35
 
 
36
 
<P><TR><TD Valign="top"><IMG SRC="icons/dbend.gif" ALT="/\"><TD bgcolor="#EEEEEE"><SMALL> If you want to change this, just <TT>Replace</TT> the parser's
37
 
private <TT>DrawStatusLine</TT> routine.  This requires a little assembly
38
 
language: see the next section for numerous examples.
39
 
</SMALL>
40
 
<TR><TD><TD><P>
41
 
 
42
 
 
43
 
About character graphic drawings: on some machines, text will by default
44
 
be displayed in a proportional font (i.e., one in which the width of a letter
45
 
depends on what it is, so that for example an 'i' will be narrower than an
46
 
'm').  If you want to display a diagram made up of letters, such as a map,
47
 
the spacing may then be wrong.  The statement <TT>font off</TT> ensures that any
48
 
fancy font is switched off and that a fixed-pitch one is being used: after
49
 
this, <TT>font on</TT> restores the usual state.
50
 
<P>
51
 
 
52
 
<P><TR><TD Valign="top"><IMG SRC="icons/warning.gif" ALT="!!"><TD><B>WARNING:</B><BR> Don't turn the <TT>font</TT> on and off in the middle of a line; this
53
 
doesn't look right on some machines.
54
 
<P>
55
 
 
56
 
<P><TR><TD Valign="top"><IMG SRC="icons/dbend.gif" ALT="/\"><TD bgcolor="#EEEEEE"><SMALL> When trying to produce a character-graphics drawing, you sometimes
57
 
want to produce the <TT>\</TT> character, one of the four "escape characters''
58
 
which can't normally be included in text.  A double <TT>@</TT> sign followed by
59
 
a number includes the character with that ASCII code; thus:
60
 
<BLOCKQUOTE>
61
 
<TT>@@64</TT> produces the literal character <TT>@</TT><BR>
62
 
<TT>@@92</TT> produces <TT>\</TT><SAMP>            </SAMP> <TT>@@94</TT> produces <TT>^</TT>
63
 
<SAMP>            </SAMP> <TT>@@126</TT> produces <TT>~</TT><BR>
64
 
</BLOCKQUOTE>
65
 
 
66
 
 
67
 
</SMALL>
68
 
<TR><TD><TD><P>
69
 
 
70
 
<P><TR><TD Valign="top"><IMG SRC="icons/ddbend.gif" ALT="/\/\"><TD bgcolor="#EEEEEE"><SMALL> Some interpreters are capable of much better character graphics
71
 
(those equipped to run the Infocom game 'Beyond Zork', for instance).
72
 
There is a way to find out if this feature is provided and to make
73
 
use of it: see the <I> Z-Machine Standards Document</I>.
74
 
</SMALL>
75
 
<TR><TD><TD><P>
76
 
 
77
 
<P><TR><TD Valign="top"><IMG SRC="icons/ddbend.gif" ALT="/\/\"><TD bgcolor="#EEEEEE"><SMALL> A single <TT>@</TT> sign is also an escape character.  It must be
78
 
followed by a 2-digit decimal number between 0 and 31 (for instance,
79
 
<TT>@05</TT>).  What this prints is the <I>n</I>-th 'variable string'.  This feature
80
 
is not as useful as it looks, since the only legal values for such
81
 
a variable string are strings declared in advance by a <TT>LowString</TT>
82
 
directive.  The <TT>String</TT> statement then sets the <I>n</I>-th variable
83
 
string.  For details and an example, see the answer to the east-west
84
 
reversal exercise in <A HREF="section10.html">Section 10</A>.
85
 
</SMALL>
86
 
<TR><TD><TD><P>
87
 
 
88
 
<P>
89
 
A distinctive feature of later Infocom games was their use of epigrams.
90
 
The assembly language required to produce this effect is easy but a
91
 
nuisance, so there is an Inform statement to do it, <TT>box</TT>.  For example,
92
 
<PRE>
93
 
box "I might repeat to myself, slowly and soothingly,"
94
 
    "a list of quotations beautiful from minds profound;"
95
 
    "if I can remember any of the damn things."
96
 
    ""
97
 
    "-- Dorothy Parker";
98
 
</PRE>
99
 
 
100
 
Note that a list of one or more lines is given (without intervening commas)
101
 
and that a blank line is given by a null string.  Remember that the text
102
 
cannot be too wide or it will look awful on a small screen.  Inform
103
 
will automatically insert the boxed text into the game transcript,
104
 
if one is being made.
105
 
The author takes the view that this device is amusing for irrelevant
106
 
quotations but irritating when it conveys vital information (such as
107
 
"Beware of the Dog").  Also, some people might be running
108
 
your game on a laptop with a vertically challenged screen, so it is
109
 
polite to provide a "quotes off'' verb.
110
 
<P>
111
 
 
112
 
A snag with printing boxes is that if you do it in the middle of a turn
113
 
then it will probably scroll half-off the screen by the time the game
114
 
finishes printing for the turn.  The right time to do so is just after
115
 
the prompt (usually <TT>&#62;</TT>) is printed, when the screen will definitely
116
 
scroll no more.  You could use the <TT>Prompt:</TT> slot in <TT>LibraryMessages</TT>
117
 
to achieve this, but a more convenient way is to put your box-printing
118
 
into the entry point <TT>AfterPrompt</TT> (called at this time each
119
 
turn).
120
 
<P>
121
 
 
122
 
<P><TR><TD Valign="top"><IMG SRC="icons/exercise.gif" ALT="??"><TD bgcolor="#FBB9AC"><A NAME="ex88"><B>EXERCISE 88:</B><BR>(link to <A HREF="answers2/answer88.html">the answer</A>)<TR><TD><TD> Implement a routine <TT>Quote(n)</TT> which will arrange for the
123
 
<I>n</I>-th quotation (where
124
 
0 &#60;= n &#60;= 49
125
 
) to be displayed at the end
126
 
of this turn, provided it hasn't been quoted
127
 
before.
128
 
<P>
129
 
 
130
 
<P>
131
 
 
132
 
Sometimes one would like to provide a menu of text options (for instance,
133
 
when producing instructions which have several topics, or when giving
134
 
clues).  This can be done with the <TT>DoMenu</TT> routine, which imitates
135
 
the traditional "Invisiclues'' style.  By setting <TT>pretty_flag=0</TT> you
136
 
can make a simple text version instead; a good idea for machines
137
 
with very small screens.
138
 
Here is a typical call to <TT>DoMenu</TT>:
139
 
<PRE>
140
 
DoMenu("There is information provided on the following:^
141
 
        ^     Instructions for playing
142
 
        ^     The history of this game
143
 
        ^     Credits^",
144
 
        HelpMenu, HelpInfo);
145
 
</PRE>
146
 
 
147
 
Note the layout, and especially the carriage returns.  The second and
148
 
third arguments are themselves routines.  (Actually the first argument
149
 
can also be a routine to print a string instead of the string itself,
150
 
which might be useful for adaptive hints.)  The <TT>HelpMenu</TT> routine
151
 
is supposed to look at the variable <TT>menu_item</TT>.  In the case when this
152
 
is zero, it should return the number of entries in the menu (3 in the
153
 
example).  In any case it should set <TT>item_name</TT> to the title for the
154
 
page of information for that item; and <TT>item_width</TT> to half its length
155
 
in characters (this is used to centre titles on the screen).
156
 
In the case of item 0, the title should be that for the whole
157
 
menu.
158
 
<P>
159
 
 
160
 
The second routine, <TT>HelpInfo</TT> above, should simply look at <TT>menu_item</TT>
161
 
(1 to 3 above) and print the text for that selection.  After this returns,
162
 
normally the game prints "Press [Space] to return to menu'' but if
163
 
the value 2 is returned it doesn't wait, and if the value 3 is returned
164
 
it automatically quits the menu as if Q had been pressed.  This is useful
165
 
for juggling submenus about.
166
 
<P>
167
 
 
168
 
Menu items can safely launch whole new menus, and it is easy to make
169
 
a tree of these (which will be needed when it comes to providing hints
170
 
across any size of game).
171
 
<P>
172
 
 
173
 
<P><TR><TD Valign="top"><IMG SRC="icons/exercise.gif" ALT="??"><TD bgcolor="#FBB9AC"><A NAME="ex89"><B>EXERCISE 89:</B><BR>(link to <A HREF="answers2/answer89.html">the answer</A>)<TR><TD><TD> Code an "Invisiclues''-style sequence of hints for a puzzle,
174
 
revealed one at a time, as a menu item.
175
 
<P>
176
 
 
177
 
<P>
178
 
Finally, you can change the text style.  The statement for this is
179
 
<TT>style</TT> and its effects are loosely modelled on the VT100 (design of
180
 
terminal). The style can be <TT>style roman</TT>, <TT>style bold</TT>, <TT>style reverse</TT> or
181
 
<TT>style underline</TT>.  Again, poor terminals may not be able to display these,
182
 
so you shouldn't hide crucial information in them.
183
 
<P>
184
 
 
185
 
<P><TR><TD Valign="top"><IMG SRC="icons/refs.gif" ALT="*"><TD bgcolor="#EEEEEE"><B>REFERENCES:</B><BR><SMALL>  'Advent' contains a menu much like that above.
186
 
<BR>
187
 
The "Infoclues'' utility program translates UHS format hints
188
 
(a standard, easy to read and write layout) into an Inform file of calls to
189
 
<TT>DoMenu</TT> which can simply be included into a game; this saves a good deal of
190
 
trouble.  
191
 
</TABLE>
192
 
<HR><A HREF="contents.html">Contents</A> / <A HREF="section31.html">Back</A> / <A HREF="section33.html">Forward</A> <BR>
193
 
<A HREF="chapter1.html">Chapter I</A> / <A HREF="chapter2.html">Chapter II</A> / <A HREF="chapter3.html">Chapter III</A> / <A HREF="chapter4.html">Chapter IV</A> / <A HREF="chapter5.html">Chapter V</A> / <A HREF="chapter6.html">Chapter VI</A> / <A HREF="chapterA.html">Appendix</A><HR><SMALL><I>Mechanically translated to HTML from third edition as revised 16 May 1997. Copyright &#169; Graham Nelson 1993, 1994, 1995, 1996, 1997: all rights reserved.</I></SMALL></BODY></HTML>