Skip to content

Tile Set Definitions

Justin Jacobs edited this page Feb 4, 2021 · 8 revisions

Tile set definitions are stored in the mods/[mod-name]/tilesetdefs/ folder.

There are five types of lines which look like this:

# cave/mines tile set
img=tileset_cave.png
tile=16,0,0,64,32,32,16
animation=16;0,0,3;64,0,3;128,0,3

Comments begin with a # symbol. These should be on a line by themselves.

img refers to a tile set image. All the tiles for a single tile set are packed into one image. A tilesetdef file should only have one img entry. The path of this file is assumed to be mods/[mod-name]/images/tilesets/

tile specifies where one tile is on the image. The data is as follows:

tile=[index],[left_x],[top_y],[width],[height],[offset_x],[offset_y]

tile entry diagram

  • index is the unique (to this tile set) integer index for this tile. This index is used in map layers (background and object). Indexes start at 1 (0 is reserved for "empty").
  • (left_x,top_y) are the top-left coordinates of the tile.
  • (width,height) are the dimensions of the tile.
  • (offset_x,offset_y) describes the drawing offset of the tile, relative to (left_x,top_y). These can be negative. The offset point of the tile matches the exact center point of the grid square. E.g. in a typical 64x32 isometric tile, the offset is 32,16.

animation is optional and specifies the animated frames for one tile. The data is as follows:

animation=[index],[left_x],[top_y],[duration];[left_x],[top_y],[duration]

The index property refers to the index of the tile you want to animate. The block of [left_x],[top_y],[duration] can be repeated. These x,y values represent the top corner of the new frame of animation. The frame size and display offset are assumed to be the same as the base tile (specified in the matching tile= line). Duration is how long to display this animation frame in seconds or milliseconds (e.g. 1s or 1000ms). A 0 duration on a frame will cause the animation to stop on that frame; otherwise the animation will loop.

Using Tile Sets

Tile sets are specified in the headers of map files. Example:

tileset=tileset_cave.txt

Multiple images in a single tileset definition

The tileset defintion can be broken up with sections, like so:

[tileset]
img=images/tileset1.png
tile=1,...

[tileset]
img=images/tileset2.png
tile=2,...