Skip to content

MakeTileset

Richard Kettering edited this page May 15, 2022 · 3 revisions

Introduction

make-tileset.pl is a perl script which outputs text. If you're unfamiliar with how to use a unix command and output its result to a file, that's beyond the scope of this tutorial, and you'll need to look up a tutorial on that online (I recommend the excellent book "Think Unix"). It's worth hinting that perl make-tileset.pl (options) > my_tileset.cfg is the general usage, but if you're unfamiliar with unix, there's no better time to learn.

make-tileset.pl was a script we wrote to automate the layout of a "single-tile-pattern"-based tileset that has an image for every combinatorially possible arrangement for a tile type. This comes out to slightly less than 50 little 16x16 images, IIRC. Because this is a nice, clean standard, we wrote a script to automatically generate the tileset files for such an arrangement - if you draw all the images, generate a file with the script, and place references to it in editor.cfg, and tiles.cfg, the tiles in the image should then be useable in frogatto.

Autotiling and Frogatto

Autotiling is a standard convention for automatically placing visual transitions/borders between tiles of different types in a tile based game. Rather than having to carefully place dozens of different border tiles in precisely the right arrangements by hand (a painstaking and error prone process), the computer automates the process by pattern matching. You, the level-maker, simply pick a kind of tile, and the computer will automatically draw in the border tiles for you.

Frogatto is very unusual in that it's entirely built around autotiling. In our map files, there are no specific tile images placed in individual locations, rather, all that is placed at different x,y locations is which type of tile will be there. This is very different from most tile-based videogames, which simply assign every tile or tile transition image a numerical ID, and input those IDs directly into the maps.

Other Notes

Frogatto leverages regex to do its pattern matching. Regex (aka "regular expressions") is a programming language used to specify and match patterns of text. Once again, though, even writing all the regexes to define how certain tiles should arrange is typically "painstaking and error prone", so this is also automated for normal-sized "complete" tile types. For a conventionally accepted arrangement of graphics in a tile sheet (which can be seen on our grey stones in rocks.png), this script will automatically define all the regexes needed to autotile it.

Frogatto's maps are also done in z-order (depth) layers, positive being nearer. Tiles with a different z-order will not autotile with each other, they will simply overlap. The z-order of a given tile is not specified in the tile itself, it is specifed in editor.cfg (which lists which tile types are in the editor's palette). Setting this causes the editor to place said tile in a given z-order layer.

Details

The syntax is <tilename> <base> <image>

Optionally you can also append: --friend <tilename> --grass <tilename> --solid (yes/no)

<tilename> is the internal mnemonic for the tile type, for example, "prk"

<base> is the position, in units of tiles, of the upper-left corner of this set of tiles in the graphic (divvied into 16x16px tiles). For example, "6m" Note that this is the REVERSE of the usual convention; it is yx, not xy. These positions are given in base-36 notation; base-36 works just like hexadecimal, in that you start using alphabetic characters to represent numbers greater than ten, except it's got 26 digits of that instead of 6. We use this so we never have to use more than 2 characters for positions.

<image> is the file name, for example "rocks.png"

--friend <tilename> allows you to make a tile (generally with a very similar appearance) work next to another type of tile at the same zorder (normally this causes problems with the pattern matching, and makes both tiles next to each other not appear at all). You'd enter something like "(prk|prg)" as the command options for this. You have to specify ALL tiles that this tile will potentially match with - if you add a new one to the set later, all the old ones need their autotile definitions regenerated accordingly. Also note that if you are using friend, the base tile mnemonic also needs to be indentical to the option passed to friend (for example, (prk|prg).

--grass says that this is a type of ground that can optionally have grass on top, and automatically lays out additional definitions for a bunch of grass tiles which are placed directly to the right of them in the tileset image (according to our convention). You specify the name of the mnemonic representing the grass (for example, "prg") as the command option. Note that if you are going to have grass, you also need to 'friend' the grass and regular tile mnemonics, as above.

--solid says that this is a type of ground that is impassible. The default is --no-solid (non-solid, passable tiles).

--noslopes indicates that this tileset does not have sloping tiles drawn, and should terrace instead.

Clone this wiki locally