#include <IsoTileSet.h>
Collaboration diagram for IsoTileSet:
Public Methods | |
IsoTileSet () | |
For the free function. More... | |
~IsoTileSet () | |
bool | loadTileset (char *name) |
Loads the tileset from a file. More... | |
bool | reloadTileset () |
If the surface was lost, reloads it, but does not reparse the file. More... | |
bool | unloadTileset () |
Performs all the necessary clean-up operations. More... | |
Uint32 | getTileCount () |
Returns the number of tiles in the tileset. More... | |
TILEINFO * | getTileList () |
Returns the list of tiles. More... | |
SDL_Surface * | getSurface () |
Returns the surface on which the tilesey resides. More... | |
char * | getFileName () |
Returns the name of the file containing the tileset in a null-terminated string. More... | |
void | putTile (SDL_Surface *destinationSurface, int xCoord, int yCoord, int tileNumber) |
Puts the tile specified onto the surface passed in. More... |
It is a fairly flexible class, but it does impose certain restrictions on the way the file is organized. First of all, there needs to be a set of control pixels in the upper-right corner of the image. The control pixels start at the coordinate (width-1, 0) and go down from there in the following order: transparency pixel, empty-region pixel, outside anchor pixel, used-region pixel, inside anchor pixel; five in all. The transparency pixel is used for color-keying, and all the pixels of that color in the image will be made transparent. The outside and inside anchor pixels do the same thing currently, and are used to denote the image anchor. When the tile is blitted using the putTile method, the anchor has the coordinates passed in to the method, and the rest of the image is drawn relatively to it. In other words, suppose we blit to rectangular tiles using the same target coordinates. One of the tiles has its anchor in the top-left corner, and the other - in the center. Then the center of the latter tile will coincide with the top-left corner of the former tile. The empty-region and used-region pixels are used to denote where the useful areas of the tile are, and which ones can be discarded. The reason for that is that the tiles in the tileset file have to be arranged in a table. In other words, all tiles in one column have to be the same width, and all the tiles in one row have to be the same height. That is not to say, however, that the width and the height have to be the equal, or that the tiles in different rows have to have the same height, and in different columns - the same width. Suppose a game has only two tiles. We can arrange them in a column. One of the tiles is square, and the other - a very thin rectangle. Then, we could mark the whole first tile as used, and for the second tile - only the space that is actually used up. Since we arranged the tiles in a column, the widths of the tiles have to be the same. However, we can mark the unused areas of the thin tile with the unused-area pixel color, and they will be discarded when blitting.
The above description seems rather confusing, despite being fairly precise. Please refer to the "CaveMan_Animation.bmp" image to see how a tileset image should be organized. A picture, after all is worth a thousand words.
Definition at line 77 of file IsoTileSet.h.
|
For the free function.
Definition at line 21 of file IsoTileSet.cpp. |
|
Definition at line 28 of file IsoTileSet.cpp. References unloadTileset. |
|
Returns the name of the file containing the tileset in a null-terminated string.
Definition at line 365 of file IsoTileSet.cpp. |
|
Returns the surface on which the tilesey resides.
Definition at line 359 of file IsoTileSet.cpp. |
|
Returns the number of tiles in the tileset.
Definition at line 349 of file IsoTileSet.cpp. Referenced by initializeEngine. |
|
Returns the list of tiles.
Definition at line 354 of file IsoTileSet.cpp. Referenced by initializeEngine, and programLoop. |
|
Loads the tileset from a file.
Definition at line 39 of file IsoTileSet.cpp. References RECT::bottom, CopyRect, getPixel, RECT::left, ImageCanvas::loadImage, OffsetRect, TILEINFO::ptAnchor, TILEINFO::rcSrc, RECT::right, RECT::top, unloadTileset, POINT::x, and POINT::y. Referenced by loadTileSets. |
|
Puts the tile specified onto the surface passed in.
Definition at line 372 of file IsoTileSet.cpp. References GetSDLRect, and OffsetRect. Referenced by renderMap. |
|
If the surface was lost, reloads it, but does not reparse the file.
Definition at line 298 of file IsoTileSet.cpp. References ImageCanvas::loadImage. |
|
Performs all the necessary clean-up operations.
Definition at line 321 of file IsoTileSet.cpp. Referenced by loadTileset, and ~IsoTileSet. |