initial commit, lordsawar source, slightly modified
[lordsawar] / doc / tile-transition.txt
1 LordsAWar Tileset Tutorial
2
3 Copyright (C) 2009 Ben Asselstine
4
5 This work is licensed under the terms of the GNU General Public License version 3 or later at your option.
6
7
8 Preface:
9
10
11 So you're interested in figuring out how the tiles fit together in LordsAWar!  This document aims to explain everything you need to know about tile graphics in the game.
12
13 This document must be viewed with a fixed-width font, and with word wrapping turned on.
14
15
16 Introduction:
17
18 There are 8 kinds of tiles: Grass, Water, Forest, Hills, Mountains, Swamp, and Void.
19
20 These kinds don't need much describing except for void -- it's the kind of tile that cannot be traveled on.
21
22 This document does not cover fog that obscures the terrain, or roads, or anything else that sits on top of the terrain tiles.
23
24 First the "tile transition scheme" will be described.
25 Then the numerous "tile styles".
26 How tile style variations are handled.
27 And finally, the tileset configuration file.
28
29
30 Tile transtion scheme
31
32 A key concept to understanding terrain tiles is the concept of a tile transition scheme.  A transition scheme is a plan that states how tiles of different kinds interact with each other.  In LordsAWar, all tile kinds transition to grass, except for mountains, which transition to hills.  It goes without saying that tiles of the same kind transition to each other; this will be described further in the section on "tile styles".
33
34 For example this means that water tiles can be placed beside grass tiles, but not forest tiles.  The consequence of this is that if we wish to depict a forest beside a stream, there must be some grass depicted in between.  It is important to note that this does not mean that there must be a grass tile in between the forest and water tiles.  It simply appears that there is a strip of grass inbetween on the border of the forest tile and the adjacent water tile.
35
36 Hill, Swamp, and Void tiles also transition to grass tiles.
37
38 Mountain tiles transition to hill tiles.  This means that all mountain tiles are completely surrounded by hill tiles (or other mountain tiles).  For example we cannot place a mountain tile beside a water tile if we're trying to depict a mountain beside a stream.  Instead we must have a hill tile that separates them.
39
40 As we pass our eyeball from the mountain to the stream we will see:
41   a mountain tile and then transitioning to a hill tile,
42   a hill tile and then transitioning to grass,
43   grass transitioning to a water tile.
44
45 There are 3 tiles.  We see mountain, hill, a little bit of grass, and then water.  
46
47 The game engine makes maps that follows the transition scheme.  If you're trying to make a set of tiles for LordsAWar, you simply have to trust that the tiles are placed together in the right way.
48
49
50 Tile Styles
51
52 Grass tiles can fit with any other grass tiles.  This style of tile is called a "Lone" tile because it can be placed beside any other grass tile.
53
54 Forest, Water, Hills, Mountains, and Void all fit together in a more complicated way that involve 16 distinct tile styles.
55
56 All of the tile styles can be described by using the following diagram:
57
58 +-----+
59 |#####|
60 |#+-+#|
61 |#|o|#|
62 |#+-+#|
63 |#####|
64 +-----+
65
66 Picture in your mind's eye a terrain feature transitioning to grass on the outside of the # box and on the inside of the box also. In the very Centre of the template is a single feature that transitions to grass on all sides (the already mentioned "lone tile").
67
68 In this section the document will refer to "transitioning to grass", but in the case of mountains it means "transitioning to hills".
69
70 First let's look at the lone tile style:
71
72 Lone
73 ooooooo
74 ooooooo
75 ooooooo
76 oooxooo
77 ooooooo
78 ooooooo
79 ooooooo
80
81
82 Picture in your mind's eye the position of that `x' in the # box diagram.  It shows that the lone tile goes beside other tiles that to transition to grass on all sides of it.  It means that this tile must look good beside all grass tiles on all sides of it. If we're dealing with a water tile, this is a puddle.  If we're dealing with a forest, this would be a small clump of trees.  There is no such thing as a lone mountain tile, because mountains transition to hills and not grass.
83
84
85
86 Next let's look at the "Outer Top-Left" tile style.
87
88 Outer Top-Left
89 xoooooo
90 ooooooo
91 ooooooo
92 ooooooo
93 ooooooo
94 ooooooo
95 ooooooo
96
97 Again, visualize where this `x' is in the # box diagram.  It shows that the "Outer Top Left" tile style needs adjcacent tiles that transitions to grass above it, and to the left.  But more importantly it shows that it needs two other particular tile styles below it, and to the right.  It is said to transition to these other tile styles. It also needs to transition to the far right and bottom left corners.
98
99 To the right of that tile is the "Outer Top-Centre" tile style:
100
101 Outer Top-Centre
102 oxxxxxo
103 ooooooo
104 ooooooo
105 ooooooo
106 ooooooo
107 ooooooo
108 ooooooo
109
110 The multiple `x's on the diagram mean that all of these tiles are the same stylistic kind in our # box diagram.  This tile style transitions to grass above it, but more importantly it transitions to the "Outer Top-Left" and "Outer Top-Right" tile styles. Unlike the previous tile style, this tile style must look good when placed horizontally beside another tile of the same tile style.   It also transitions down to the "Inner Middle-Centre" tile style.
111
112 The other outer corners mirror the top left corner.  Use the the same thought-process to understand which sides of the following tile styles transition to grass, and which tile styles they transition to.
113
114 Outer Top-Right
115 oooooox
116 ooooooo
117 ooooooo
118 ooooooo
119 ooooooo
120 ooooooo
121 ooooooo
122
123 Outer Bottom-Left
124 ooooooo
125 ooooooo
126 ooooooo
127 ooooooo
128 ooooooo
129 ooooooo
130 xoooooo
131
132 Outer Bottom-Right
133 ooooooo
134 ooooooo
135 ooooooo
136 ooooooo
137 ooooooo
138 ooooooo
139 oooooox
140
141 You can imagine that these corner tile styles could be placed beside each other to form a small enclosed shape that transitions to grass on all sides.  If we were dealing with water, this would be a puddle, but a different looking one from the one depicted in the lone tile.
142
143 Here is the Inner Middle-Centre tile style.  In a way it's the opposite of the lone tile.  Unlike the other tile styles, grass is nowhere to be found on this tile style.  If the kind of tile we're dealing with is forest, then this tile style is solid forest.  If it's water, then it's water on all sides.  
144
145 Inner Middle-Centre
146 ooooooo
147 oxxxxxo
148 oxoooxo
149 oxoooxo
150 oxoooxo
151 oxxxxxo
152 ooooooo
153
154 This tile style transitions to a lot of other tile styles... all of them that start with the word "inner", or "outer".
155
156
157 Mirroring the Outer Top-Centre tile style are the following tile styles:
158
159
160 Outer Bottom-Centre
161 ooooooo
162 ooooooo
163 ooooooo
164 ooooooo
165 ooooooo
166 ooooooo
167 oxxxxxo
168
169 Whereas the Outer Top-Centre tile style transitioned to grass in the up direction, the Outer Bottom-Centre tile style transitions to grass in the down direction.
170
171
172 Outer Middle-Left
173 ooooooo
174 xoooooo
175 xoooooo
176 xoooooo
177 xoooooo
178 xoooooo
179 ooooooo
180
181
182 Outer Middle-Right
183 ooooooo
184 oooooox
185 oooooox
186 oooooox
187 oooooox
188 oooooox
189 ooooooo
190
191
192 The outside perimeter of the # box diagram has been described.  Now let's look at the inside of the box.
193
194
195 Inner Top-Left
196 ooooooo
197 ooooooo
198 ooxoooo
199 ooooooo
200 ooooooo
201 ooooooo
202 ooooooo
203
204 Here we have the Inner Top-Left tile style.  You can imagine that it must transition to grass in it's bottom right corner.  Conversely you can imagine that it must transition to mostly hills/water/forest above it and to it's right.  You can also imagine that it must transition to particular tile styles to it's immediate right and below it.  It also transitions with two of its mirror corners -- Inner Top-Tight, and the Inner Bottom-Left.
205
206
207 The mirror corners of the Inner Top-Left tile style:
208
209 Inner Top-Right
210 ooooooo
211 ooooooo
212 ooooxoo
213 ooooooo
214 ooooooo
215 ooooooo
216 ooooooo
217
218
219 Inner Bottom-Left
220 ooooooo
221 ooooooo
222 ooooooo
223 ooooooo
224 ooxoooo
225 ooooooo
226 ooooooo
227
228 Inner Bottom-Right
229 ooooooo
230 ooooooo
231 ooooooo
232 ooooooo
233 ooooxoo
234 ooooooo
235 ooooooo
236
237 "But wait!" You say.  "I can't see which tile style the Inner Top-Left tile style transitions to on it's immediate right."  "You've explained that it has to transition with it's two mirror corners, and I can see those, but where is the tile style that it transitions to on it's right?"
238
239
240 We need a tile style that transitions to grass in the down direction.  The missing tile style is the Outer Bottom-Centre tile style.  Yes we're in the "inner" side of the box, and we're depending on a tile style from the "outer" side of the box to complete the picture.  This means that certain inner tile styles need to look good beside certain outer tile styles.  By using the # box diagram you can figure out which tile styles those are.
241
242
243 Finally we have the diagonal tile styles.  Visually they merge the tilestyles depicted in the given 1 and 2 positions:
244
245 Top-Left To Bottom-Right Diagonal
246 1oooooo
247 ooooooo
248 ooooooo
249 ooooooo
250 ooooooo
251 ooooooo
252 oooooo2
253
254 This tile transitions to grass in the upper right and the bottom left.
255
256 Bottom-Left To Top-Right Diagonal
257 oooooo1
258 ooooooo
259 ooooooo
260 ooooooo
261 ooooooo
262 ooooooo
263 2oooooo
264
265 This tile transitions to grass int he upper left and the bottom right.
266
267 Imagine two of our # box diagrams that connect at the corner.  We need a diagonal tile to connect them properly.
268
269 Lastly there's an "Other" tile style that can be placed by hand in the scenario editor.
270
271 The game engine makes maps that put the correct tile styles next to each other.  The artist must trust that the game does this properly.
272
273
274 Tile Style Variations
275
276 A Tile style variation is a depiction of a particular tile style that is drawn in a slightly different manner.  For example there can be many depictions of the Inner Middle-Centre tile style.  For a water tile, this represents open sea and it's important to have lots of variation so that the water looks good.
277
278 When the game engine needs a picture of a tile that has a tile style of Inner Middle-Centre, it goes and gets one from the tileset by pulling out a random picture that reports itself as being of that tile style.  Any one will do.
279
280 In general it's good to have at least two of each tile style, with 10 of Inner Middle-Centre, and at least 10 of the grassy lone tiles.
281
282
283 The tileset configuration file.
284
285 Once we have all of the images completed, we have to put it all together into a single data file.
286
287 The XML entity that relates most directly with this tutorial is the "<tilestyleset>" entity.  Here's what the default grass tilestyle set looks like:
288
289
290         <tilestyleset>
291                 <d_name>grass</d_name>
292                 <tilestyle> <d_id>0x00</d_id> <d_type>0</d_type> </tilestyle>
293                 <tilestyle> <d_id>0x01</d_id> <d_type>16</d_type> </tilestyle>
294                 <tilestyle> <d_id>0x02</d_id> <d_type>0</d_type> </tilestyle>
295                 <tilestyle> <d_id>0x03</d_id> <d_type>0</d_type> </tilestyle>
296                 <tilestyle> <d_id>0x04</d_id> <d_type>0</d_type> </tilestyle>
297                 <tilestyle> <d_id>0x05</d_id> <d_type>0</d_type> </tilestyle>
298                 <tilestyle> <d_id>0x06</d_id> <d_type>0</d_type> </tilestyle>
299                 <tilestyle> <d_id>0x07</d_id> <d_type>0</d_type> </tilestyle>
300                 <tilestyle> <d_id>0x08</d_id> <d_type>0</d_type> </tilestyle>
301                 <tilestyle> <d_id>0x09</d_id> <d_type>0</d_type> </tilestyle>
302         </tilestyleset>
303
304
305 Don't let the hexadecimal numbers fool you.  This is is simple.  "<d_name>" refers to an image file called "grass.png" that is in the same folder as this tileset configuration file.  The grass.png file has 10 frames, left to right.  Each frame happens to be called a "tilestyle" and is uniquely identified with that hexadecimal number.  This id is unique among all frames in the tileset configuration file.
306 The "<d_type>" entity is a numeric code that refers to which kind of tile style this frame depicts.  The first frame in the tilestyleset says it is of type 0, which is really a lone tile style.
307
308 Here is the key of number-codes to tile styles:
309
310 0   Lone
311 1   Outer Top-Left
312 2   Outer Top-Centre
313 3   Outer Top-Right
314 4   Outer Bottom-Left
315 5   Outer Bottom-Centre
316 6   Outer Bottom-Right
317 7   Outer Middle-Left
318 8   Inner Middle-Centre
319 9   Outer Middle-Right
320 10  Inner Top-Left
321 11  Inner Top-Right
322 12  Inner Bottom-Left
323 13  Inner Bottom-Right
324 14  Top-Left to Bottom-Right Diagonal
325 15  Bottom-Left to Top-Right Diagonal
326 16  Other
327
328 Near the top of the tileset configuration file you will see a line that looks like "<d_tilesize>80</d_tilesize>".  This means that the grass.png file will be 800 pixels wide and 80 pixels tall.
329
330
331 Final Words
332
333 Now you have an idea of what is involved in making tilesets for LordsAWar.  If you need more help, please check out the tutorial videos at www.lordsawar.com for a audio-visual reiteration of some of this information.
334