1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
4
<title>DM4 §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">
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="§8: Places and scenery">prev</a> /
14
<a href="s10.html" title="§10: Food and drink">next</a> /
15
<a href="dm4index.html">index</a>
18
<a id="p122" name="p122"></a>
19
<h2>§9 Directions and the map</h2>
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 – as I fear you have found.<br>
25
— J. R. R. Tolkien (1892–1973), to Naomi Mitchison,
26
25 April 1954</blockquote>
28
<p class="normal"><span class="atleft"><img src="dm4-122_1.jpg" alt=""></span>
29
‘Ruins’ 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">§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>
36
<p class="lynxonly"></p>
37
<table align="center" class="objtree">
38
<tr><td><tt>Square Chamber</tt></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>
44
<tr><td><tt>Shrine</tt></td></tr>
47
<p class="normal">To make these map connections, we need to add:</p>
49
<p class="lynxonly"></p>
50
<pre class="code">u_to Forest, e_to Wormcast, s_to Corridor,</pre>
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
56
<p class="lynxonly"></p>
58
u_to "The trees are spiny and you'd cut your hands to ribbons
59
trying to climb them.",
60
cant_go "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.",
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 “You can't go that way”. 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>
78
<a id="p123" name="p123"></a>
79
<p class="aside"><span class="warning">▲</span>
80
Here's how this is done. When the library wants to go in a certain
81
direction, let's say “north”, it sends the message
82
<code>location.n_to()</code> and looks at the reply: it takes
83
<code>false</code> to mean “Player can't go that way” and
84
says so; <code>true</code> means “Player can't go that way,
85
and I've already said why”; and any other value is taken as
88
<a id="ex8" name="ex8"></a>
89
<p class="aside"><span class="warning"><b>•</b>
90
<b><a href="sa6.html#ans8">EXERCISE 8</a></b></span><br>
91
Many early games have rooms with confused exits: ‘Advent’
92
has Bedquilt, ‘Acheton’ has a magnetic lodestone which
93
throws the compass into confusion, ‘Zork II’ has a
94
spinning carousel room and so on. Make the Wormcast room in
95
‘Ruins’ similarly bewildering.</p>
97
<p class="dotbreak">� � � � �</p>
99
<p class="normal">For each of the twelve standard Inform directions
100
there is a “direction property”:</p>
102
<p class="lynxonly"></p>
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
108
<p class="normal">Each direction also has a “direction object”
109
to represent it in the game. For instance, <code>n_obj</code> is
110
the object whose name is “north” and which the player
111
invokes by typing “go north” or just “n”.
112
So there are normally twelve of these, too:</p>
114
<p class="lynxonly"></p>
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
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 “go north”, 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>
127
<p class="aside"><span class="warning">▲</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 “north”
132
made by the library:</p>
134
<p class="lynxonly"></p>
136
CompassDirection n_obj "north wall" compass
137
with name 'n' 'north' 'wall', door_dir n_to;
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">§13</a>) and here tells Inform which
144
direction property corresponds to which direction object.</p>
146
<a id="p124" name="p124"></a>
147
<a id="ex9" name="ex9"></a>
148
<p class="aside"><span class="warning"><b>•</b>▲
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án
151
Peninsula had ‘world colours’ 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 ‘sunset’, hence
155
black, the colour of night). Implement this.</p>
157
<a id="ex10" name="ex10"></a>
158
<p class="aside"><span class="warning"><b>•</b>▲
159
<b><a href="sa6.html#ans10">EXERCISE 10</a></b></span><br>
160
In Level 9's version of ‘Advent’, the magic word “xyzzy”
161
was implemented as a thirteenth direction. How can this be done?</p>
163
<a id="ex11" name="ex11"></a>
164
<p class="aside"><span class="warning"><b>•</b>▲
165
<b><a href="sa6.html#ans11">EXERCISE 11</a></b></span><br>
166
(Cf. ‘Trinity’.) How can the entire game map be
167
suddenly east�west reflected?</p>
169
<a id="ex12" name="ex12"></a>
170
<p class="aside"><span class="warning"><b>•</b>▲▲
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 “east” and “west” by name.
174
Reflect these too.</p>
176
<a id="ex13" name="ex13"></a>
177
<p class="aside"><span class="warning"><b>•</b>▲▲
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
185
<p class="aside"><span class="warning"><b>•</b>
186
<b>REFERENCES</b></span><br>
187
‘Advent’ 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.
193
<span class="warning"><b>•</b></span>For a simple movement rule
194
using <code>e_to</code>, see the Office in ‘Toyshop’.
195
<span class="warning"><b>•</b></span>The opening location of Infocom's
196
‘Moonmist’ provides a good example of <code>cant_go</code> used
197
to guide the player in a tactful way: “(The castle is south of
199
<span class="warning"><b>•</b></span>The library extension <tt>"smartcantgo.h"</tt>
200
by David Wagner provides a system for automatically printing out
201
“You can only go east and north.”-style messages.
202
<span class="warning"><b>•</b></span>Ricardo Dague's <tt>"cmap.h"</tt>
203
constructs maps of American-style cities. The same author's <tt>"makemaze.inf"</tt>
204
prints out Inform source code for random rectangular mazes.
205
<span class="warning"><b>•</b></span>Nicholas Daley and Gunther Schmidl
206
have each independently written a <tt>"dirs.h"</tt>
207
providing a “dirs” or “exits” verb which
208
lists available exits. Marnie Parker's <tt>"dirsmap.h"</tt>
209
goes further by plotting up exits in map style or writing them out
210
in English, at the player's discretion.
211
<span class="warning"><b>•</b></span>Brian D. Smith's example program
212
<tt>"spin.inf"</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 “left”, “right”,
215
“ahead” and “back”.</p>
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="§8: Places and scenery">prev</a> /
223
<a href="s10.html" title="§10: Food and drink">next</a> /
224
<a href="dm4index.html">index</a>