An ASGE supported tile.
Tiles, whilst sharing much of the same functionality as the ASGE::Sprite are conceptually quite different. Instead they are used to build more complex scenes and game maps. Because of this their position is normally dictated by the map itself and typically consists of using rows, columns and tile sizes to determine their exact positioning.
The aim of this struct is to easily allow this kind of functionality to exist within ASGE. Now instead of having to construct instances of Sprites with their own positional data, you can use a Tile instead.
When rendering a Tile you will need to provide the XY position that it's to appear in World Space. Remember that by default origins in ASGE for positions (not rotations) are calculated from the top-left.
Mozilla's developer documentation (https://developer.mozilla.org/en-US/docs/Games/Techniques/Tilemaps) does a great job of introducing tile maps and how conceptually they operate. This might help if you're unsure about when you would use a Tile instead of a Sprite.
Mozilla Developer Docs
Example:
auto& tile = tiles.emplace_back();
tile.texture = renderer->createCachedTexture("/data/img/tile_sheet.png");
tile.width = 64
tile.height = 64
tile.src_rect = {0, 0, 64, 64};
for (int row=0; row < map.length; ++row) {
for (int col=0; col < map.length; ++col) {
renderer->render(tiles[row][col],
}
}
Definition at line 70 of file Tile.hpp.