9

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.

Anko
  • 13,393
  • 10
  • 54
  • 82
Ben Hollier
  • 259
  • 2
  • 9
  • 1
    I'm not really sure how this went from "minecraft chunks" to "pixel tiles", but it seems you have an answer. Also, potential duplicate for the chunk question: http://gamedev.stackexchange.com/questions/46955/why-is-chunk-size-often-a-power-of-two?rq=1 and for the new question: http://gamedev.stackexchange.com/questions/26187/why-are-textures-always-square-powers-of-two-what-if-they-arent?rq=1 – House May 06 '15 at 18:34

1 Answers1

9

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.

Uwe Plonus
  • 830
  • 8
  • 12
  • Being a power of two is one thing. But also technical limitations on older platforms and sprite engines favoured those tile sizes. – aggsol May 06 '15 at 06:57
  • 1
    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). – Jelle van Campen May 06 '15 at 07:54
  • 4
    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. – DMGregory May 06 '15 at 18:00