baba-is-auto
C++17 Baba Is You simulator
Loading...
Searching...
No Matches
baba_is_auto::Map Class Reference

Map class. More...

#include <Map.hpp>

Public Member Functions

 Map ()=default
 Default constructor.
 
 Map (std::size_t width, std::size_t height)
 
void Reset ()
 Resets map data.
 
std::size_t GetWidth () const
 
std::size_t GetHeight () const
 
void Load (std::string_view filename)
 
void AddObject (std::size_t x, std::size_t y, ObjectType type)
 
void RemoveObject (std::size_t x, std::size_t y, ObjectType type)
 
ObjectAt (std::size_t x, std::size_t y)
 
const ObjectAt (std::size_t x, std::size_t y) const
 
std::vector< PositionGetPositions (ObjectType type) const
 

Detailed Description

Map class.

This class represents map. A map is a board of the game.

Constructor & Destructor Documentation

◆ Map() [1/2]

baba_is_auto::Map::Map ( )
default

Default constructor.

◆ Map() [2/2]

baba_is_auto::Map::Map ( std::size_t  width,
std::size_t  height 
)

Constructs map with given width and height.

Parameters
widthThe size of the width.
heightThe size of the height.

Member Function Documentation

◆ AddObject()

void baba_is_auto::Map::AddObject ( std::size_t  x,
std::size_t  y,
ObjectType  type 
)

Adds an object to the map.

Parameters
xThe x position.
yThe y position.
typeAn object type to add to the map.

◆ At() [1/2]

Object & baba_is_auto::Map::At ( std::size_t  x,
std::size_t  y 
)

Gets a writable object reference from the map.

Parameters
xThe x position.
yThe y position.
Returns
A writable object reference at the zero-based (x, y) position.

◆ At() [2/2]

const Object & baba_is_auto::Map::At ( std::size_t  x,
std::size_t  y 
) const

Gets an object from the map.

Parameters
xThe x position.
yThe y position.
Returns
An object at row and column.

◆ GetHeight()

std::size_t baba_is_auto::Map::GetHeight ( ) const

Gets the height of the map.

Returns
The height of the map.

◆ GetPositions()

std::vector< Position > baba_is_auto::Map::GetPositions ( ObjectType  type) const

Gets a list of icon positions.

Parameters
typeAn object type to get a list of positions.
Returns
A list of icon positions.

◆ GetWidth()

std::size_t baba_is_auto::Map::GetWidth ( ) const

Gets the width of the map.

Returns
The width of the map.

◆ Load()

void baba_is_auto::Map::Load ( std::string_view  filename)

Loads the data of the map.

Parameters
filenameThe file name to load.
Exceptions
std::runtime_errorIf the map data is invalid.

◆ RemoveObject()

void baba_is_auto::Map::RemoveObject ( std::size_t  x,
std::size_t  y,
ObjectType  type 
)

Removes an object from the map.

Parameters
xThe x position.
yThe y position.
typeAn object type to remove from the map.

◆ Reset()

void baba_is_auto::Map::Reset ( )

Resets map data.


The documentation for this class was generated from the following file: