OrthoMap.tileAtPoint

Get the tile at a given pixel position on the map. Throws if out of bounds.

struct OrthoMap(Tile)
ref
Tile
tileAtPoint
(
T
)
(
T pos
)
if (
isPixelCoord!T
)

Parameters

T

any pixel-positional point (see isPixelCoord).

pos
Type: T

pixel location in 2D space

Examples

1 auto grid = [
2   [ 00, 01, 02, 03, 04, ],
3   [ 10, 11, 12, 13, 14, ],
4   [ 20, 21, 22, 23, 24, ],
5 ];
6 
7 auto map = OrthoMap!int(grid, 32, 32);
8 
9 assert(map.tileAtPoint(PixelCoord(  0,  0)) == 00); // corner of top left tile
10 assert(map.tileAtPoint(PixelCoord( 16, 30)) == 00); // inside top left tile
11 assert(map.tileAtPoint(PixelCoord(149, 95)) == 24); // inside bottom right tile

Meta