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

« back to all changes in this revision

Viewing changes to inform-6.31.1/manual/s9.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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 
2
<html>
 
3
<head>
 
4
<title>DM4 &#167;9: Directions and the map</title>
 
5
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
 
6
<link rel="stylesheet" type="text/css" href="dm4.css">
 
7
</head>
 
8
<body>
 
9
<p class="navbar">
 
10
 <a href="index.html">home</a> /
 
11
 <a href="contents.html">contents</a> /
 
12
 <a href="ch3.html" title="Chapter III: The Model World">chapter III</a> /
 
13
 <a href="s8.html" title="&#167;8: Places and scenery">prev</a> /
 
14
 <a href="s10.html" title="&#167;10: Food and drink">next</a> /
 
15
 <a href="dm4index.html">index</a>
 
16
</p>
 
17
<div class="page">
 
18
<a id="p122" name="p122"></a>
 
19
<h2>&#167;9 &nbsp; Directions and the map</h2>
 
20
 
 
21
<blockquote>I wisely started with a map, and made the story fit 
 
22
(generally with meticulous care for distances). The other way about 
 
23
lands one in confusions and impossibilities, and in any case it is 
 
24
weary work to compose a map from a story &#8211; as I fear you have found.<br>
 
25
&#8212; J. R. R. Tolkien (1892&#8211;1973), to Naomi Mitchison, 
 
26
25 April 1954</blockquote>
 
27
 
 
28
<p class="normal"><span class="atleft"><img src="dm4-122_1.jpg" alt=""></span>
 
29
&#8216;Ruins&#8217; so far contains two disconnected rooms. It is 
 
30
time to extend it into a modest map in which, as promised, the Square 
 
31
Chamber lies underneath the original Forest location. For the map 
 
32
of the finished game, see <a href="s23.html">&#167;23</a> below, 
 
33
but here is the beginning of the first level beneath ground, showing 
 
34
the Square Chamber and its two main side-chambers:</p>
 
35
 
 
36
<p class="lynxonly"></p>
 
37
<table align="center" class="objtree">
 
38
<tr><td><tt>Square Chamber</tt></td>
 
39
 <td>&#8212;</td>
 
40
 <td><tt>Wormcast</tt></td></tr>
 
41
<tr><td>|</td><td colspan="2" rowspan="4"></tr>
 
42
<tr><td><tt>Corridor</tt></td></tr>
 
43
<tr><td>|</td></tr>
 
44
<tr><td><tt>Shrine</tt></td></tr>
 
45
</table>
 
46
 
 
47
<p class="normal">To make these map connections, we need to add:</p>
 
48
 
 
49
<p class="lynxonly"></p>
 
50
<pre class="code">u_to Forest, e_to Wormcast, s_to Corridor,</pre>
 
51
 
 
52
<p class="normal">to the Square Chamber. This seems a good point to 
 
53
add two more map connections, or rather non-connections, to the Forest 
 
54
as well:</p>
 
55
 
 
56
<p class="lynxonly"></p>
 
57
<pre class="code">
 
58
u_to &quot;The trees are spiny and you'd cut your hands to ribbons
 
59
    trying to climb them.&quot;,
 
60
cant_go &quot;The rainforest is dense, and you haven't hacked
 
61
    through it for days to abandon your discovery now. Really,
 
62
    you need a good few artifacts to take back to civilization
 
63
    before you can justify giving up the expedition.&quot;,
 
64
</pre>
 
65
 
 
66
<p class="normal">The property <code>cant_go</code> contains what 
 
67
is printed when the player tries to go in a nonexistent direction, 
 
68
and replaces &#8220;You can't go that way&#8221;. Instead of
 
69
giving an actual message you can give a routine to print one out, 
 
70
to vary what's printed with the circumstances. The Forest needs a 
 
71
<code>cant_go</code> because in real life one could go in every 
 
72
direction from there: what we're doing is explaining the game 
 
73
rules to the player: go underground, find some ancient treasure, 
 
74
then get out to win. The Forest's <code>u_to</code> property is 
 
75
a string of text, not a room, and this means that attempts to go 
 
76
up result only in that string being printed.</p>
 
77
 
 
78
<a id="p123" name="p123"></a>
 
79
<p class="aside"><span class="warning">&#9650;</span>
 
80
Here's how this is done. When the library wants to go in a certain 
 
81
direction, let's say &#8220;north&#8221;, it sends the message 
 
82
<code>location.n_to()</code> and looks at the reply: it takes
 
83
<code>false</code> to mean &#8220;Player can't go that way&#8221; and 
 
84
says so; <code>true</code> means &#8220;Player can't go that way, 
 
85
and I've already said why&#8221;; and any other value is taken as 
 
86
the destination.</p>
 
87
 
 
88
<a id="ex8" name="ex8"></a>
 
89
<p class="aside"><span class="warning"><b>&#8226;</b>
 
90
<b><a href="sa6.html#ans8">EXERCISE 8</a></b></span><br>
 
91
Many early games have rooms with confused exits: &#8216;Advent&#8217; 
 
92
has Bedquilt, &#8216;Acheton&#8217; has a magnetic lodestone which 
 
93
throws the compass into confusion, &#8216;Zork II&#8217; has a
 
94
spinning carousel room and so on. Make the Wormcast room in 
 
95
&#8216;Ruins&#8217; similarly bewildering.</p>
 
96
 
 
97
<p class="dotbreak">� � � � �</p>
 
98
 
 
99
<p class="normal">For each of the twelve standard Inform directions 
 
100
there is a &#8220;direction property&#8221;:</p>
 
101
 
 
102
<p class="lynxonly"></p>
 
103
<pre class="code">
 
104
n_to     s_to     e_to     w_to     d_to     u_to
 
105
ne_to    nw_to    se_to    sw_to    in_to    out_to
 
106
</pre>
 
107
 
 
108
<p class="normal">Each direction also has a &#8220;direction object&#8221; 
 
109
to represent it in the game. For instance, <code>n_obj</code> is 
 
110
the object whose name is &#8220;north&#8221; and which the player
 
111
invokes by typing &#8220;go north&#8221; or just &#8220;n&#8221;. 
 
112
So there are normally twelve of these, too:</p>
 
113
 
 
114
<p class="lynxonly"></p>
 
115
<pre class="code">
 
116
n_obj    s_obj    e_obj    w_obj    d_obj    u_obj
 
117
ne_obj   nw_obj   se_obj   sw_obj   in_obj   out_obj
 
118
</pre>
 
119
 
 
120
<p class="normal">Confusing the direction objects with the direction 
 
121
properties is easily done, but they are quite different. When the 
 
122
player types &#8220;go north&#8221;, the action is <code>Go n_obj</code>, 
 
123
with <code>noun</code> being <code>n_obj</code>: only when this action 
 
124
has survived all possible before rules is the <code>n_to</code> value 
 
125
of the current location looked at.</p>
 
126
 
 
127
<p class="aside"><span class="warning">&#9650;</span>
 
128
The set of direction objects is not fixed: the current direction 
 
129
objects are the children of a special object called <code>compass</code>, 
 
130
and the game designer is free to add to or take from the current 
 
131
stock. Here for instance is the definition of &#8220;north&#8221; 
 
132
made by the library:</p>
 
133
 
 
134
<p class="lynxonly"></p>
 
135
<pre class="code">
 
136
CompassDirection n_obj &quot;north wall&quot; compass
 
137
  with name 'n' 'north' 'wall', door_dir n_to;
 
138
</pre>
 
139
 
 
140
<p class="aside"><code>CompassDirection</code> is a class defined 
 
141
by the library for direction objects. <code>door_dir</code> is
 
142
a property more usually seen in the context of doors (see 
 
143
<a href="s13.html">&#167;13</a>) and here tells Inform which 
 
144
direction property corresponds to which direction object.</p>
 
145
 
 
146
<a id="p124" name="p124"></a>
 
147
<a id="ex9" name="ex9"></a>
 
148
<p class="aside"><span class="warning"><b>&#8226;</b>&#9650;
 
149
<b><a href="sa6.html#ans9">EXERCISE 9</a></b></span><br>
 
150
In the first millennium A.D., the Maya peoples of the Yucat&aacute;n 
 
151
Peninsula had &#8216;world colours&#8217; white (<i>sac</i>), 
 
152
red (<i>chac</i>), yellow (<i>kan</i>) and black (<i>chikin</i>) 
 
153
for what we call the compass bearings north, east, south, west 
 
154
(for instance west is associated with &#8216;sunset&#8217;, hence 
 
155
black, the colour of night). Implement this.</p>
 
156
 
 
157
<a id="ex10" name="ex10"></a>
 
158
<p class="aside"><span class="warning"><b>&#8226;</b>&#9650;
 
159
<b><a href="sa6.html#ans10">EXERCISE 10</a></b></span><br>
 
160
In Level 9's version of &#8216;Advent&#8217;, the magic word &#8220;xyzzy&#8221; 
 
161
was implemented as a thirteenth direction. How can this be done?</p>
 
162
 
 
163
<a id="ex11" name="ex11"></a>
 
164
<p class="aside"><span class="warning"><b>&#8226;</b>&#9650;
 
165
<b><a href="sa6.html#ans11">EXERCISE 11</a></b></span><br>
 
166
(Cf. &#8216;Trinity&#8217;.) How can the entire game map be 
 
167
suddenly east�west reflected?</p>
 
168
 
 
169
<a id="ex12" name="ex12"></a>
 
170
<p class="aside"><span class="warning"><b>&#8226;</b>&#9650;&#9650;
 
171
<b><a href="sa6.html#ans12">EXERCISE 12</a></b></span><br>
 
172
Even when the map is reflected, there may be many room descriptions 
 
173
referring to &#8220;east&#8221; and &#8220;west&#8221; by name. 
 
174
Reflect these too.</p>
 
175
 
 
176
<a id="ex13" name="ex13"></a>
 
177
<p class="aside"><span class="warning"><b>&#8226;</b>&#9650;&#9650;
 
178
<b><a href="sa6.html#ans13">EXERCISE 13</a></b></span><br>
 
179
Some designers find it a nuisance to have to keep specifying all 
 
180
map connections twice: once east from <i>A</i> to <i>B</i>, then a second time 
 
181
west from <i>B</i> to <i>A</i>, for instance. Write some code to go in the 
 
182
<code>Initialise</code> routine making all connections automatically 
 
183
two-way.</p>
 
184
 
 
185
<p class="aside"><span class="warning"><b>&#8226;</b>
 
186
<b>REFERENCES</b></span><br>
 
187
&#8216;Advent&#8217; has a very tangled-up map in places (see the 
 
188
mazes) and a well-constructed exterior of forest and valley giving 
 
189
an impression of space with remarkably few rooms. The mist object uses 
 
190
<code>found_in</code> to the full, and see also the stream (a single 
 
191
object representing every watercourse in the game). Bedquilt and 
 
192
the Swiss Cheese room offer classic confused-exit puzzles. &nbsp;
 
193
<span class="warning"><b>&#8226;</b></span>For a simple movement rule 
 
194
using <code>e_to</code>, see the Office in &#8216;Toyshop&#8217;. &nbsp;
 
195
<span class="warning"><b>&#8226;</b></span>The opening location of Infocom's 
 
196
&#8216;Moonmist&#8217; provides a good example of <code>cant_go</code> used 
 
197
to guide the player in a tactful way: &#8220;(The castle is south of 
 
198
here.)&#8221; &nbsp;
 
199
<span class="warning"><b>&#8226;</b></span>The library extension <tt>&quot;smartcantgo.h&quot;</tt> 
 
200
by David Wagner provides a system for automatically printing out 
 
201
&#8220;You can only go east and north.&#8221;-style messages.
 
202
<span class="warning"><b>&#8226;</b></span>Ricardo Dague's <tt>&quot;cmap.h&quot;</tt> 
 
203
constructs maps of American-style cities. The same author's <tt>&quot;makemaze.inf&quot;</tt> 
 
204
prints out Inform source code for random rectangular mazes.
 
205
<span class="warning"><b>&#8226;</b></span>Nicholas Daley and Gunther Schmidl 
 
206
have each independently written a <tt>&quot;dirs.h&quot;</tt> 
 
207
providing a &#8220;dirs&#8221; or &#8220;exits&#8221; verb which 
 
208
lists available exits. Marnie Parker's <tt>&quot;dirsmap.h&quot;</tt> 
 
209
goes further by plotting up exits in map style or writing them out 
 
210
in English, at the player's discretion. &nbsp;
 
211
<span class="warning"><b>&#8226;</b></span>Brian D. Smith's example program 
 
212
<tt>&quot;spin.inf&quot;</tt> abolishes the convention that a player 
 
213
has an in-built ability to know which way is north: it replaces conventional 
 
214
compass directions with &#8220;left&#8221;, &#8220;right&#8221;, 
 
215
&#8220;ahead&#8221; and &#8220;back&#8221;.</p>
 
216
 
 
217
</div>
 
218
<p class="navbar">
 
219
 <a href="index.html">home</a> /
 
220
 <a href="contents.html">contents</a> /
 
221
 <a href="ch3.html" title="Chapter III: The Model World">chapter III</a> /
 
222
 <a href="s8.html" title="&#167;8: Places and scenery">prev</a> /
 
223
 <a href="s10.html" title="&#167;10: Food and drink">next</a> /
 
224
 <a href="dm4index.html">index</a>
 
225
</p>
 
226
</body>
 
227
</html>
 
228