idGivenWidth

fun idGivenWidth(width: Int): Int

Calculates x + y * width

Each tile in a 2D Grid with n = width * height elements can be uniquely represented as an integer from 0 to n - 1. ID'ing tiles like this can be useful for associating additional information with them using arrays, instead of less performant maps.

Return

The unique integer id of the tile.

Parameters

width

The width of the grid the tile belongs to.