|
Aegis2D
Modular C++26 2D game engine for networked games
|
A TileMap ready to draw: the textures of its tilesets and where each tile is in them. More...
#include <aegis2d/render/tile_map_view.hpp>
Public Member Functions | |
| TileMapView (const TileMap &map, TextureManager &textures) | |
| Loads the image of each tileset as a texture, named by its path. | |
| void | draw (IRenderer &renderer, std::int32_t first_layer=0) const |
| Draws every visible tile layer, from the bottom one. | |
| void | draw_layer (IRenderer &renderer, std::size_t layer, std::int32_t sprite_layer) const |
| Draws one layer, if it is a visible tile layer. | |
A TileMap ready to draw: the textures of its tilesets and where each tile is in them.
Each tile of a tile layer is a sprite, placed as Tiled shows it: in its cell, bottom-left aligned when its tileset's tiles are larger than the cells, shifted by the layer's offset, with the layer's opacity, flipped left to right or top to bottom by the bits of its global id. Hidden layers are not drawn. With a camera on the renderer, only the cells around Camera::visible() are drawn, so a map of any size costs the tiles of one screen; the renderer batches them, one draw call per tileset and layer.
Tiles flipped along their diagonal (rotated in Tiled) are drawn without that flip: sprites do not rotate.
| aegis2d::render::TileMapView::TileMapView | ( | const TileMap & | map, |
| TextureManager & | textures | ||
| ) |
Loads the image of each tileset as a texture, named by its path.
| map | Map to draw; it must outlive the view and keep its layers. |
| textures | Manager that loads the images, each file once. |
| ImageError | if an image cannot be read. |
| void aegis2d::render::TileMapView::draw | ( | IRenderer & | renderer, |
| std::int32_t | first_layer = 0 |
||
| ) | const |
Draws every visible tile layer, from the bottom one.
| renderer | Renderer in a frame, with the camera the map is seen through. |
| first_layer | Sprite layer of the map's first layer; layer i of the map goes on first_layer + i, so the layers stack as in Tiled. |
| void aegis2d::render::TileMapView::draw_layer | ( | IRenderer & | renderer, |
| std::size_t | layer, | ||
| std::int32_t | sprite_layer | ||
| ) | const |
Draws one layer, if it is a visible tile layer.
| renderer | Renderer in a frame. |
| layer | Index in TileMap::layers. |
| sprite_layer | Sprite layer to draw it on. |
| std::out_of_range | if layer is not below the number of layers. |