File room.hpp

Typedefs

using json = nlohmann::json

Variables

constexpr const char *DEFAULT_PLAYER_PATH = "actors/playerActor.ractor"
class Room : public ISaveable
#include <room.hpp>

This class represents a game’s room. It can contain the Player, interactables, collisions and the TileMap

Public Functions

Room()

Empty constructor

Room(const std::string &fileName, int tileSize = 48, bool createPlayer = true)

Construct a Room from an .rmap file

Room(std::unique_ptr<TileMap> tileMap)

Construct a Room by using a TileMap pointer

Room(const RoomBin &bin)

Construct a Room by using the RoomBin binary structure

Parameters:

bin – The binary structure to use

virtual json dumpJson()

Dump the room’s data into a nlohmann::json object for later use Useful for dumping into a .json file.

Returns:

The JSON object

void unload() const

Unload used resources. Typically unloads used Textures by calling raylib’s UnloadTexture

void update()

Update routine for this Room.

void draw() const

Draw routine for this Room.

void setWorldTileSize(int tileSize)
int getWorldTileSize() const
void setLock(bool val)
void addPlayer(std::unique_ptr<Player> newPlayer)

Add the Player into this Room. A unique_ptr is passed whose ownership will be moved into the Room.

Parameters:

newPlayer – A pointer to the player that will be moved into this Room.

Player &getPlayer() const

Get a reference to the Player object.

Returns:

The Player in this Room.

TileMap *getTileMap() const

Get a pointer to this Room’s TileMap.

Returns:

A pointer to the room’s TileMap.

void setTileMap(TileMap *newTileMap)
std::string getMusicSource() const

Get filename of the source music.

void setMusicSource(const std::string_view &newMusicSource)

Set music source.

Vector2 getStartTile() const

Get the start tile position.

void setStartTile(Vector2 newStartTile)

Set the start tile position.

CollisionsContainer &getCollisions() const

Get a reference to the CollisionsContainer of this Room.

InteractablesContainer &getInteractables() const

Get a reference to the InteractablesContainer of this Room.

PropsContainer &getProps() const

Get a reference to the PropsContainer of this Room.

ActorContainer &getActors()

Get a refernece to the collection of Actors.

Private Functions

void updateCamera()

Private Members

bool lock
int worldTileSize
Camera2D camera = {}

The camera.

Vector2 startTile = {}

Start point of the player. (tile position)

std::string musicSource

Source of the background music for this room.

std::unique_ptr<InteractablesContainer> interactables

Container of the interactable tiles

std::unique_ptr<CollisionsContainer> collisions

Container of the collision tiles

std::unique_ptr<PropsContainer> props

Container of the props

std::unique_ptr<TileMap> tileMap

This Room’s TileMap, which contains all placed tiles.

std::unique_ptr<ActorContainer> actors

A collection of all Actors in this Room

std::unique_ptr<Player> player

This Room’s only Player.