Revision 1.0 by Dino M. Gambone Introduction If you are reading this article, then you probably know what an isometric tile is. Most isometric games store the tile images in a single bitmap and simply bitblt the tile image from the tile bitmap to the destination surface. There is nothing wrong with this method except that the tile information is fixed. There is very little room for changing tile attributes on the fly. The following article proposes a file, called a tileset, which stores the tile images along with some properties of the tiles. Tilesets make maps more robust since different maps can have different tilesets and be more dynamic than traditional isometric map games. The Tileset Anatomy The tileset is broken up into 3 basic sections. These sections are as follows:
The Tileset Header Every file, no matter how simplistic or complex, should always have a header section. This is simply just good practice. The tileset file is no exception. The tileset header should contain information about the tileset itself and common information about the tiles in the tileset. Some recommended members of the tileset header are: file version, tileset engine name, tileset codename, and tileset description. These along with some custom header values should be enough to create a stable tileset file. The Tile Entry Index Table A tileset should not have the restriction that the tiles in it are stored in sequential order. In fact, to enforce such a rule would be too time consuming and inefficient since tile images can vary in size. It is easier, faster, and more efficient if the tileset had an internal 'table of contents'. That is what the Tile Entry Index Table is for. It is simply an array of unsigned longs which indicate the byte location of the tile in the tileset. A value of0 would indicate that there is no tile for that tile ID. With the Entry Table, one can quickly find the byte index of the image. The Entry List The tile entry list is a back-to-back tile entries. These entries do not have to be in sequential order. This is the meat of the tileset. Every entry can be represented by the following struct:
struct TSFILEENTRY{ unsigned char TileID; //Unique numeric tile ID unsigned char TileLength; //Length of the tile unsigned char TileWidth; //Width of the tile unsigned char TileHeight; //The 'altitude' of the tile char BaseOffset; //Location of tile base unsigned int ImgSize; //Size of the actual tile image char *ImgData; //An array of byte that is the image }; Tileset Maintainance Now that you know how a tileset file is structured, it is important to cover some key issues needed to maintain a tileset.
We got a file... now what? We got a file... now what? The next logical step is to create the engine that reads and writes to the tileset file and returns the tile attributes on demand. Be sure that your tileset engine is open-ended enough so that you can encapsulate it in game specific map engine. You got the tile image and the tile information. Most people will load the tile images to a single bitmap and remember where the image is located at. I highly recommend this method, but you may have a better way of showing your tiles. From here on... it's up to you! :) Conclusion All ideas in this document were developed by me for a particular map engine in mind. I don't claim them to be the greatest and best way of doing things. I offer these article as a means to share ideas with others so that they may develop an even better way of doing things. If you have any questions, feel free to email me at the above email address. Discuss this article in the forums
See Also: © 1999-2011 Gamedev.net. All rights reserved. Terms of Use Privacy Policy
|