Game programming




Tile based map. Part1.

Tile based map.

by Vladimir Vasilyev


First of all, we restrict possible terrain type position concerning each other. It means tiles representing different terrain type may neighbour with one or two definite terrain type not with all.

Let arrangement is : water-ground-grass-tree. Water and tree may have the only neighbor - ground and grass accordingly.

Pic. 1 : Terrain  precedence  ordering from low type (water) to hi one (tree).

Thus we need three tile sets for four terrain types:
Set1 for water-ground transition - map brush is ground
Set2 for ground-grass transition - map brush is grass
Set3 for grass-tree transition     - map brush is tree.

Any tile within some tile set will be determine by 8 bits - low 4 bits for the edges and Hi 4 bits for the corners.

The next step is to define direction order, in which we will check neighbour tiles for the current selected tile. You may see they on the Pic2 (left) . Also the bit assignments order for the edges and corners will be the same. It  shown on the Pic 2(center).

Pic.2 : Direction and checking bit correlation.

Note that for the proper map:

 bit 0 equal bit 2
 bit 1 equal bit 3
 bit 2 equal bit 0 
 bit 3
equal bit 1
and so on...- because there will be the same terrain type.

For any tile set we have two different terrain type. One of them we will consider as the Hi type and other as the Low type.

For Hi type we will set according bit to 1 and for Low type we will set according bit to 0.

If you have some difficulties of bit manipulation - see Bit manipulation demo.

To sum up, we shall present the next common terrain transition bit model for certain tile set.

 Pic. 3 : Common terrain transition bit model.

You can see the edge and corner tiles and theirs bit representation proceed in normal binary manner: 0000,0001,0010 and so on...

We can reduce the number of different tile type by replacing some tiles as shown on the Pic4.

Pic. 4 : Reduced  terrain transition bit model.

The final tile set for ground-grass is shown on the bottom.

Pic. 5-6 : Real  terrain tile set.

 Copyright    2001   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


in game graphics

coming soon










Hosted by uCoz