libtcod
Loading...
Searching...
No Matches
Tilesets (C++)

Tileset loading and handling functions. More...

Classes

struct  tcod::TilesetDeleter
class  tcod::Tileset
 A C++ Tileset container. More...

Typedefs

typedef std::unique_ptr< TCOD_Tileset, TilesetDeletertcod::TilesetPtr
 A unique pointer to a TCOD_Tileset.

Functions

template<typename ArrayType>
auto tcod::load_tilesheet (const std::filesystem::path &path, const std::array< int, 2 > &columns_rows, const ArrayType &charmap) -> Tileset
 Load a tilesheet from a PNG file.
auto tcod::load_bdf (const std::filesystem::path &path) -> TilesetPtr
 Load a Tileset from a BDF font file.

Detailed Description

Tileset loading and handling functions.

Typedef Documentation

◆ TilesetPtr

typedef std::unique_ptr<TCOD_Tileset, TilesetDeleter> tcod::TilesetPtr

A unique pointer to a TCOD_Tileset.

embed:rst:leading-asterisk 
.. versionadded:: 1.19

Function Documentation

◆ load_bdf()

auto tcod::load_bdf ( const std::filesystem::path & path) ->TilesetPtr
inline

Load a Tileset from a BDF font file.

Will throw an exception on a missing or corrupt file.

embed:rst:leading-asterisk 
.. versionadded:: 1.19

◆ load_tilesheet()

template<typename ArrayType>
auto tcod::load_tilesheet ( const std::filesystem::path & path,
const std::array< int, 2 > & columns_rows,
const ArrayType & charmap )->Tileset
inline

Load a tilesheet from a PNG file.

An exception will be thrown if the file is missing or corrupt.

Tiles are indexed in row-major order and should be assigned to Unicode codepoints.

embed:rst:leading-asterisk 
.. versionadded:: 1.19
Template Parameters
ArrayTypeMust be a std::vector or std::array like type. With size() and data() methods.
Parameters
pathThe file path to the PNG tilesheet image.
columns_rowsThe shape of the grid on the tileset as {columns, rows}.
charmapAn array of characters where charmap[tile_index] = codepoint. tcod::CHARMAP_CP437 or tcod::CHARMAP_TCOD are typical values for this argument.
Returns
TilesetPtr A unique pointer to a TCOD_Tileset.