Game programming




Tile based map. Part1.

Tile based map.
by Vladimir Vasilyev
translated from russian by Yuliya Semenchenco

The article based on the ideas by

David Michael  : "Tile/Map-Based Game Techniques: Handling Terrain Transitions"
Ivan Dyshlenko : "Creation map edit  for strategy games like Warcraft"  
Tile graphics was obtained from WarCraft II  screenshots.


The new terms.
Further term tile will be used also for a bits representation of a graphic image. (Probably now it`s hard to understand, but I am sure, that in the necessary place of the text you will understand everything, about what is going on, if you are not  - write me.)

Type of a surface - WATER, GROUND, WOOD, STONES, BOGS etc.


Beginning work with the editor of map, first of all, it will be necessary to define the laws on which game objects will be cooperate with each other in the created game world, how they can settle down on a game field as to each other and as to the borders of the game world. Not all of them directly are needed for creation of the map, but the map - not the end in itself. The created model should correlate with sprite engine, which can work with this map.

Model of the game world.

In this passage the following model is examined :
1. The game map consists of the tiles.
2. Any tile can consist no more than of two types of surface.
3. Each type of surface can border with one or two STRICTLY determinated types of surface.

The given model will essentially allow to reduce the amount of the  original tiles, which are necessary for creation of the map.

Let`s accept the following order of arrangement of the types of surface:
(see fig. 1)

Fig. 1


According to our rules WATER can border only on GROUND and WOOD only on GRASS.  

The new terms.  
  For any tile, consisting of two types of surfaces, a type of surface which was situated in the earlier accepted order of arrangement more to the left, we shall call as low type, more to the right - high type.
  Similarly it`s defined the "seniority" for two any other chosen types of surfaces.

    The mathematical model.

Now we came to the most interesting part- how transform our model to the language of numbers. If we imagine, that our map is already constructed, (look at fig. 2) is easy to understand, that any tile is undoubtfully defining  by its nearest neighbours. 

There are 8 of such neighbours. The number 8 by itself should already inspire you with optimism - you can completely describe tile in one byte. But ahead of we can expect for more pleasant coincidences. From 8 neighbours 4 of them  border on the corners and 4 - on the sides of chosen tile. 4 is a half-byte, and  it can be easy to receive access, as well as to byte!

So, we can describe any tile by 8 bits. LOW 4 bits  we use for the description of the sides,  HIGH 4 bits for the description of the corners. (look at fig. 3-4)

Fig. 2 Fig. 3


If you don`t know the exact meaning of the word "bit",especially for you here is prepared the demonstration program  Bit manipulation demo.

Fig. 4

Thus, it will be a logical thing to define the following order according to which the nearest neighbours of the chosen tile will be checked and to establish precisely the same proportion between the order of following(?) of bits and numeration of the edges(sides) and tops(apexes). The order you can see at a fig. 5 (at the left), and   proportion between the order of following(?) of bits and   by apexes and edges(sides) in the fig. 5 (at the centre).

The considered tile is painted in light green, the nearest neighbours -  in light blue. 

Fig. 5:   Direction and checking bit correlation.


It is necessary to notice, that for the constructed self-coordinated map:

  bit 0 is equal bit 2
  bit 1 is equal bit 3
  bit 2 is equal bit 0  
  bit 3 is equal bit 1
Etc....- Since there should be identical types of surfaces.

As it was defined earlier, any tile  can include no more than two types of surfaces. Thus one type of surface is considered  as Low type, another - as   Hi type.

For Hi type will correspond to 1 and for Low type -to 0.

Designing of sets

The new terms.
The brush of a set or its name is defined by HI type of the tiles.

Due to item 3 of our model,we need  only three sets of the tiles for a map creation with four types of surface:

SET1 for transition(transformation) WATER - GROUND  (brush "ground" = 1)
SET2 for transition GROUND - GRASS  (brush "grass" = 2)
SET2 for transition GRASS - WOOD   (brush "wood" = 3)

As long as all sets are arranged equally, we shall consider the certain generalized set WHITE -BLACK  for a map construction with two types of surfaces - white and black.

Accurately examine all possible combinations of the arrangement of types of surfaces on borders of the tiles we shall find out that the edges(sides) and corners(apexes) and their bit representations can be arranged in ordinary binary manner: 0000,0001,0010 and so on...

  a fig. 6: Common terrain transition bit model.

Moreover, it is possible to reduce amount of the  original tiles for a set changing its graphics. Notice, that the mathematical representation of the such tiles do not change!!! Compare fig. 6 and fig. 7.

Fig. 7: Reduced   terrain transition bit model.

The real GROUND -  GRASS set, based on a stated above technique, which is given below .

Fig. 8: Real   terrain tile set.

Copyright    2001-2002   Vladimir Vasilyev.  
Any part of given clause, including illustrations, in any purposes can not be reproduced in any form and any means without the written permission  of the author. 

Site Navigator



coming soon










Hosted by uCoz