

We start by checking for a tile to the North. The green square in the figure above represents the terrain tile we are calculating. This Boolean result is then multiplied by the binary directional value and added to the running total of the bitmasking value-it's easier to understand with some examples: 4-bit Directional Values

In thisĮxample, we are assuming a single terrain type with no corner pieces.Ĭhecks for the existence of tiles to the North, West, East, and South, and eachĬheck returns a Boolean, where 0 represents an empty space and 1 signifies the Calculating the Bitmasking ValueĬalculating this value is relatively simple. For now, it's important to understand how the bitmasking value relates to the terrain tileset. The sprites are ordered sequentially so that a bitmasking value of 0 returns the first sprite, all the way to a value of 15 which returns the 16 th sprite.
#TIDE TILE MAP EDITOR HOW TO#
The numbers on each tile represent the bitmasking value, which we will learn how to calculate in the next section. The sprite sheet above consists of terrain tiles with all of the possible border configurations. In a tileset is numbered, and the bitmasking process returns a number corresponding to the position of a sprite in the tileset. At runtime, theīitmasking procedure is performed, and every tile is updated with the appropriate Neighboring tiles to determine which sprite from the set to assign to itself. Tile bitmasking is all about calculating a numerical value andĪssigning a specific sprite based on that value. Each tile looks at its In this tutorial, we will cover the basics of tile bitmasking while working our way towards more complicated implementations that use corner tiles and multiple terrain types.

With a few small tweaks, you can expand bitmasking to allow for dynamic tiles that change during gameplay. With a static implementation of bitmasking, maps are generated at runtime. Drawing this many different sprites is definitely a time-consuming process, but tile bitmasking ensures that the act of placing these tiles is quick and efficient. When dealing with multiple types of terrain, the number of different variations can exceed 300 or more tiles.
#TIDE TILE MAP EDITOR DOWNLOAD#
(You can download the demos and source files from the GitHub repo.) Tile Bitmasking: An Auto-Tiling Solution for Level Design
