5#include <aegis2d/render/export.hpp>
25class AEGIS2D_RENDER_EXPORT
TileMapError :
public std::runtime_error {
27 using std::runtime_error::runtime_error;
32using TileProperty = std::variant<bool, std::int64_t, double, std::string>;
52 std::uint32_t first_gid = 1;
56 std::filesystem::path image{};
62 std::uint32_t tile_count = 0;
94 std::optional<std::uint32_t>
gid{};
139 std::vector<Tileset> tilesets{};
141 std::vector<MapLayer> layers{};
150 [[nodiscard]]
static TileMap load(
const std::filesystem::path& path);
Thrown when a map or one of its tilesets cannot be read or is broken.
Definition tile_map.hpp:25
OpenGL renderer: sprites, text and camera (client only).
Definition bitmap_font.hpp:16
constexpr std::uint32_t tile_id_mask
Bits of a global tile id that are the id, without the flip bits.
Definition tile_map.hpp:46
constexpr std::uint32_t flip_horizontal
Bit of a global tile id set when the tile is flipped left to right.
Definition tile_map.hpp:39
aegis2d::Vec2 Vec2
2D vector of floats, in logical pixels: the engine-wide aegis2d::Vec2.
Definition renderer.hpp:17
constexpr std::uint32_t flip_diagonal
Bit of a global tile id set when the tile is flipped along its diagonal.
Definition tile_map.hpp:43
constexpr std::uint32_t flip_vertical
Bit of a global tile id set when the tile is flipped top to bottom.
Definition tile_map.hpp:41
std::variant< bool, std::int64_t, double, std::string > TileProperty
Value of a custom property: bool, int (and object, its id), float, or string (and color,...
Definition tile_map.hpp:32
std::map< std::string, TileProperty, std::less<> > TileProperties
Custom properties of a map, layer, object or tileset, by name.
Definition tile_map.hpp:35
Backend-independent renderer interface and the sprite it draws.
Frames of a sprite sheet: the rectangles of a texture that a sprite shows in turn.
Layer of tiles or of objects.
Definition tile_map.hpp:102
bool visible
Shown in Tiled.
Definition tile_map.hpp:111
float opacity
From 0 (transparent) to 1.
Definition tile_map.hpp:113
TileProperties properties
Custom properties.
Definition tile_map.hpp:117
Vec2 offset
Offset in pixels.
Definition tile_map.hpp:115
std::string name
Name given in Tiled.
Definition tile_map.hpp:104
std::vector< std::uint32_t > tiles
For a tile layer, the global id of each cell (flip bits included), row by row from the top-left,...
Definition tile_map.hpp:107
std::vector< TileObject > objects
For an object layer, its objects in order; empty for a tile layer.
Definition tile_map.hpp:109
Rectangle of a texture, in whole pixels from its top-left corner.
Definition sprite_sheet.hpp:14
Width and height of a texture, in pixels.
Definition renderer.hpp:38
Orthogonal, finite map made in Tiled, saved as JSON.
Definition tile_map.hpp:131
const Tileset * tileset(std::uint32_t gid) const noexcept
Tileset of a tile.
static TileMap load(const std::filesystem::path &path)
Reads a map and its external tilesets.
const MapLayer * layer(std::string_view name) const noexcept
First layer of a name.
Shape placed on the map: a spawn point, a trigger area, a tile placed freely.
Definition tile_map.hpp:80
Vec2 size
Size in pixels; 0 for a point.
Definition tile_map.hpp:90
Vec2 position
Top-left corner in pixels (bottom-left for a tile object, as in Tiled).
Definition tile_map.hpp:88
std::string name
Name given in Tiled.
Definition tile_map.hpp:84
float rotation
Rotation in degrees, clockwise.
Definition tile_map.hpp:92
bool visible
Shown in Tiled.
Definition tile_map.hpp:96
TileProperties properties
Custom properties.
Definition tile_map.hpp:98
std::optional< std::uint32_t > gid
Global id of the tile it shows (flip bits included), if it is a tile object.
Definition tile_map.hpp:94
std::string type
Class given in Tiled (type before Tiled 1.9).
Definition tile_map.hpp:86
Image cut into tiles; its tiles are the global ids first_gid to first_gid + tile_count - 1.
Definition tile_map.hpp:50
PixelRect tile(std::uint32_t index) const
Rectangle of a tile in the image.