Construct an orthogonal tilemap from a rectangular (non-jagged) grid of tiles.
True if the pixel position is within the map bounds.
Get the grid location corresponding to a given pixel coordinate.
Get the tile at a given pixel position on the map. Throws if out of bounds.
Get the pixel offset of the center of the tile at the given coord.
Get the pixel offset of the top-left corner of the tile at the given coord.
Height of each tile in pixels
Width of each tile in pixels
The underlying tile grid structure, surfaced with alias this.
Foreach over every tile in the map
1 import std.algorithm : equal; 2 3 auto grid = [ 4 [ 00, 01, 02, ], 5 [ 10, 11, 12, ], 6 ]; 7 auto myMap = OrthoMap!int(grid, 32, 64); 8 9 int[] result; 10 11 foreach(tile ; myMap) result ~= tile; 12 13 assert(result.equal([ 00, 01, 02, 10, 11, 12 ]));
Use ref with foreach to modify tiles
1 auto grid = [ 2 [ 00, 01, 02, ], 3 [ 10, 11, 12, ], 4 ]; 5 auto myMap = OrthoMap!int(grid, 32, 64); 6 7 foreach(ref tile ; myMap) tile += 30; 8 9 assert(myMap.tileAt(RowCol(1,1)) == 41);
Foreach over every (coord, tile) pair in the map
1 import std.algorithm : equal; 2 3 auto grid = [ 4 [ 00, 01, 02, ], 5 [ 10, 11, 12, ], 6 ]; 7 auto myMap = OrthoMap!int(grid, 32, 64); 8 9 10 foreach(coord, tile ; myMap) assert(myMap.tileAt(coord) == tile);
Generic Tile Map structure that uses a single layer of tiles in an orthogonal grid.
This provides a 'flat' representation of multiple tile and object layers. T can be whatever type you would like to use to represent a single tile within the map.
An OrthoMap supports all the operations of dtiled.grid for working with RowCol coordinates. Additionally, it stores information about tile size for operations in pixel coordinate space.