Class TileMap

class TileMap

A TileMap represents a map of the placed tiles in a Room.

Public Functions

TileMap(const std::string &fileName)

Construct from a file name/path

TileMap(const std::string &tileSetSource, int width, int height, int atlasTileSize, int worldTileSize)

Construct using a TileSet path, width, height

TileMap(const TileSet &tileSet, int width, int height, int atlasTileSize, int worldTileSize)

Constructor using a TileSet object

TileMap(std::unique_ptr<TileSet> tileSetPtr, int width, int height, int atlasTileSize, int worldTileSize)

Constructor using a unique_ptr of a TileSet

TileMap(const RoomBin &bin)

Constructor using a RoomBin binary structure

json dumpJson()

Dump the TileMap’s data into a nlohmann::json object

void unload() const

Unload routine. Typically calls raylib’s UnloadTexture.

void update() const

Update routine.

void draw() const

Draw routine.

std::string getTileSetSource() const

Get the path of the TileSet resource

TileSet *getTileSet() const

Get a pointer to the used TileSet

void setTileSet(const std::string &tileSetSource)

Set a new TileSet for this TileMap using a path for the new TileSet

Tile getTile(int x, int y) const

Get the Tile at the specified x and y position

void setTile(Vector2 worldPos, Vector2 atlasPos)

Set the tile at the specified world position to be a tile at the specified atlas position from the TileSet.

void setEmptyTile(Vector2 worldPos)

Set the tile at the specified world position to be empty (not drawn).

void drawTile(int x, int y) const

Draw the tile at the specified world x and y coordinates.

Vector2 getMaxWorldSize() const

Get the size of this TileMap

Returns:

the size in a Vector2. The x component is the width; the y component is the height.

void setWorldSize(Vector2 size)

Set the size of this TileSet using the provided Vector2 argument. The x ocmponent will be the new width; the y component will be the new height.