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
import std.algorithm : equal; auto grid = [ [ 00, 01, 02, ], [ 10, 11, 12, ], ]; auto myMap = OrthoMap!int(grid, 32, 64); int[] result; foreach(tile ; myMap) result ~= tile; assert(result.equal([ 00, 01, 02, 10, 11, 12 ]));
Use ref with foreach to modify tiles
auto grid = [ [ 00, 01, 02, ], [ 10, 11, 12, ], ]; auto myMap = OrthoMap!int(grid, 32, 64); foreach(ref tile ; myMap) tile += 30; assert(myMap.tileAt(RowCol(1,1)) == 41);
Foreach over every (coord, tile) pair in the map
import std.algorithm : equal; auto grid = [ [ 00, 01, 02, ], [ 10, 11, 12, ], ]; auto myMap = OrthoMap!int(grid, 32, 64); 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.