![]() |
FastEngine 0.9.3
A multiplayer oriented 2D engine made with Vulkan.
|
A class that represent a set of tiles that can be used in a TileLayer. More...
#include <C_tileset.hpp>
Public Types | |
using | TileListType = std::set<fge::TileData, std::less<>> |
Public Member Functions | |
TileSet (fge::Texture texture) | |
TileSet (fge::Texture texture, fge::Vector2i const &tileSize) | |
TileSet (fge::Texture texture, fge::Vector2i const &tileSize, fge::Vector2i const &offset) | |
void | clearTiles () |
Clear the tiles. | |
void | setName (std::string name) |
Set the name of the TileSet. | |
std::string const & | getName () const |
Get the name of the TileSet. | |
bool | valid () const |
Check if the TileSet have a valid Texture. | |
fge::Texture const & | getTexture () const |
Get the texture of the TileSet. | |
void | setTexture (fge::Texture texture) |
Set the texture of the TileSet. | |
fge::Vector2i const & | getTileSize () const |
Get the tile size of the TileSet. | |
void | setTileSize (fge::Vector2i const &tileSize) |
Set the tile size of the TileSet. | |
fge::Vector2i const & | getOffset () const |
Get the offset in pixel of the TileSet. | |
void | setOffset (fge::Vector2i const &offset) |
Set the offset in pixel of the TileSet. | |
std::size_t | getTileCount () const |
Get the total number of tiles in the TileSet. | |
fge::TileData const * | getTile (TileId id) const |
Retrieve a tile by its local id. | |
TileId | getLocalId (fge::Vector2i const &position) const |
Get the local id of a tile by its grid position. | |
TileId | getLocalId (TileId gid) const |
Get the local id of a tile by its global id. | |
bool | isGidContained (TileId gid) const |
Check if the global id is in the tileset. | |
void | setFirstGid (TileId gid) |
Set the first global id of the tileset. | |
TileId | getFirstGid () const |
Get the first global id of the tileset. | |
TileListType::const_iterator | begin () const |
TileListType::const_iterator | end () const |
void | slice () |
Slice the texture into tiles. | |
int | getColumns () const |
Return the number of columns in the texture. | |
int | getRows () const |
Return the number of rows in the texture. | |
std::optional< fge::RectInt > | getTextureRect (TileId id) const |
Get the texture rectangle of a tile by its local id. | |
fge::RectInt | computeTextureRect (TileId id) const |
Compute the supposed texture rectangle with a local id. | |
fge::TileSet & | operator= (fge::Texture texture) |
A class that represent a set of tiles that can be used in a TileLayer.
This class is compatible with the "Tiled" map editor.
void fge::TileSet::clearTiles | ( | ) |
Clear the tiles.
|
nodiscard |
Compute the supposed texture rectangle with a local id.
id | The local id of the tile |
|
nodiscard |
Return the number of columns in the texture.
|
nodiscard |
Get the first global id of the tileset.
|
nodiscard |
Get the local id of a tile by its grid position.
position | The grid position of the tile |
|
nodiscard |
Get the local id of a tile by its global id.
The global id is subtracted by the first global id of the tileset in order to get the local id.
gid | The global id of the tile |
|
nodiscard |
|
nodiscard |
|
nodiscard |
Return the number of rows in the texture.
|
nodiscard |
|
nodiscard |
Get the texture rectangle of a tile by its local id.
id | The local id of the tile |
|
nodiscard |
Retrieve a tile by its local id.
id | The local id of the tile |
|
nodiscard |
|
nodiscard |
|
nodiscard |
Check if the global id is in the tileset.
gid | The global id of the tile |
void fge::TileSet::setFirstGid | ( | TileId | gid | ) |
Set the first global id of the tileset.
The first global id correspond to the first tile id in the tileset.
gid | The first global id of the tileset |
void fge::TileSet::setName | ( | std::string | name | ) |
void fge::TileSet::setOffset | ( | fge::Vector2i const & | offset | ) |
void fge::TileSet::setTexture | ( | fge::Texture | texture | ) |
void fge::TileSet::setTileSize | ( | fge::Vector2i const & | tileSize | ) |
void fge::TileSet::slice | ( | ) |
Slice the texture into tiles.
The texture will be sliced into tiles of the size specified by the tile size. Tiles is always sliced from the top left corner of the texture in a Z pattern.
Previous tiles will be cleared.
|
nodiscard |