9
\$\begingroup\$

Is there any good reason for tiles (e.g. Minecraft's) to be 16×16?

I have a feeling it has something to do with binary because 16 is 10000 in binary, but that might be a coincidence.

I want to know is because I want to make a game with terrain generation, and I want to know how big my tiles should be, or if it doesn't really matter.

\$\endgroup\$
9
\$\begingroup\$

Tiles and icons (even in UIs like window systems) are often in a size like 16x16 or 24x24 to make it easier to modify the tiles. Most times the tile size is a multiple of 8 because of the folowing reasons.

  • It is relatively easy to shrink a tile with the size 32x32 to 16x16 by simply putting 4 pixels together (e.g. create the median/average of the 4 pixels). If you have a tile size like 17x17 you have difficulties to shrink the size.

  • Most screen resolutions are also a multiple of 8, e.g. 1920x1200 (the typical HD resoltion for monitors) leads to a game field with 120x75 tiles (when using a tile size of 16x16).

  • Calculations with 2 tiles (e.g. overlaying a terrain with a character) is easier in programming languages if the tile size is a multiple of 8. Often the exists some optimizations for such tile sizes.

  • Historical reasons: Most earlier sprite engines (in home computers and game consoles) had limitation to force the tiles to be 8x8 or 16x16. (added after comment from Code Clown)

TL;DR It is easier to handle tile sizes that are multipes of 8.

So there are several reasons to use tile sizes like 16x16, 24x24 or 32x32.

\$\endgroup\$
  • \$\begingroup\$ Being a power of two is one thing. But also technical limitations on older platforms and sprite engines favoured those tile sizes. \$\endgroup\$ – aggsol May 6 '15 at 6:57
  • 1
    \$\begingroup\$ Indeed, for example the NES console used tiles of 8x8. Therefore, the dimensions of object sprites and character sprites are often multiples of 8 (e.g. the sprite for Mario in SMB1 is a 16x32 sprite, consisting of eight 8x8 tiles). \$\endgroup\$ – Jelle van Campen May 6 '15 at 7:54
  • 4
    \$\begingroup\$ An additional advantage of power-of-2 sizes (8, 16, 32) in 2D tile-based games is that converting between pixel coordinates and tile coordinates can be done with a single bitwise shift (shift right to get the tile under a given pixel, shift left to get the pixel position of a tile). In 3D games, power-of-two sizes allow mipmapping, which improves the look of distant/slanted surfaces and improves GPU texture cache performance. \$\endgroup\$ – DMGregory May 6 '15 at 18:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.