The nfo/grf Tutorial


Since TTD is a palette-based game, you'll have to be careful about the used graphics program dealing properly with 8-bit graphics. In addition, TTD uses some of its palette entries for colour-animation by palette cycling. Be aware to not use these as regular colours.

Below is an explanation by Oskar Eisemuth of the various colour ranges in the DOS and Windows palettes. Both palettes work similarly, but some of the colours are in different places. In addition, the Windows palette includes less colour entries than the DOS palette.


Note: Normal colours are marked in green. Colours using palette cycling or translation are marked yellow. In any way, don't use the red marked colours (Windows API).

Colours in the "company" range may be changed by the game into the current player colours. In some instances, they may be changed to colours specified by the .grf file, or random colours, or not changed at all.

Here is a list of the shades of player colours that will be used by the game:


The "Patch Company 2" range isn't normally a special colour range, but only since 2.0.1 alpha 67 it is possible to use it as a second company colour for vehicles and town houses.

The palette cycling ranges listed are the water cycle (used for the blinking dots in the water), the block cycle, fire cycle, flashing red (used for crossing lights), and the yellow cycle (used for the lighthouse, or for the runway lights of the large airport).

The following tables provide more detailed information on differences between DOS and Windows colours and colour indices:


TTD internally uses a 3D engine, which then uses an isometric projection to display graphics on a 2D screen. The 3D engine uses so-called "bounding boxes" for each sprite, which are then sorted by the sprite sorter to get drawn in (what it thinks is) the right order.

To get a certain sprite drawn at the right place, it needs to have a proper bounding box (which is provided by the game for the most part), and the correct 2D offsets, here called "xofs" and "yofs" (see RealSprites for more information). The following picture by Oskar Eisemuth should help in figuring out how the 3D and 2D coordinates relate to each other:


For 3D coordinates, X goes from top right to bottom left, Y goes from top left to bottom right, and Z (height) from down to up. For 2D coordinates, X goes from left to right, and Y from top to bottom. Usually, the top side of the screen is referred to as "north", and thus "east", "south" and "west" are the right, bottom and left side of the screen.

For vehicles, the center of the bounding box (shown with a red dot in the yellow boxframe) is the reference point from which the xofs and yofs are counted. This means that in most cases, xofs and yofs need to be negative to get the sprite to fit on the box. Normally, as indicated above, this means xofs is approximately the negative value of half the sprite width, and yofs is approximately the negative value of half the sprite height.

For all other sprites, the reference point is the furthest corner of the box, at its lowest X, Y and Z coordinates, i.e. the lower northernmost corner. In the image above, it is indicated by the crossing point of the blue lines. The xofs and yofs work from this point, instead of the center of the box as for vehicles.