2020-02-19 18:50:09 +01:00
|
|
|
#ifndef LEVEL_H
|
|
|
|
#define LEVEL_H
|
|
|
|
|
|
|
|
#include <array>
|
|
|
|
|
2020-02-21 15:29:06 +01:00
|
|
|
enum class CellType
|
2020-02-21 15:20:40 +01:00
|
|
|
{
|
|
|
|
Water = '.',
|
|
|
|
Ground = '-',
|
|
|
|
Charge = '$',
|
2020-02-21 15:29:06 +01:00
|
|
|
Bridge = char(177),
|
2020-02-25 17:53:57 +01:00
|
|
|
Hero = '@',
|
2020-02-25 18:09:38 +01:00
|
|
|
Exit = '#',
|
|
|
|
Wall = 'X'
|
2020-02-21 15:20:40 +01:00
|
|
|
};
|
|
|
|
|
2020-02-21 15:13:12 +01:00
|
|
|
using coordinate = unsigned int;
|
|
|
|
constexpr coordinate side = 32;
|
2020-02-19 18:50:09 +01:00
|
|
|
|
2020-02-21 15:20:40 +01:00
|
|
|
using Row = std::array<CellType, side>;
|
2020-02-20 19:34:41 +01:00
|
|
|
using Map = std::array<Row, side>;
|
2020-02-19 18:50:09 +01:00
|
|
|
|
2020-02-21 15:20:40 +01:00
|
|
|
/// Abstraction over 2D array to quickly get access to level cells
|
2020-02-19 18:50:09 +01:00
|
|
|
class Level
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
Map map;
|
|
|
|
|
|
|
|
public:
|
|
|
|
Level();
|
2020-02-20 19:34:41 +01:00
|
|
|
|
|
|
|
/// Place a bridge cell
|
2020-02-21 15:13:12 +01:00
|
|
|
void placeBridge(coordinate x, coordinate y);
|
2020-02-20 19:34:41 +01:00
|
|
|
|
|
|
|
/// Get the 2D array of level map
|
2020-02-21 22:55:13 +01:00
|
|
|
Map& mapArray();
|
2020-02-20 19:34:41 +01:00
|
|
|
|
2020-02-25 17:53:57 +01:00
|
|
|
/// Returns type of requested map cell
|
|
|
|
CellType cellOfType(coordinate x, coordinate y) const;
|
2020-02-20 19:34:41 +01:00
|
|
|
|
|
|
|
/// Replace a charge cell with a ground cell
|
2020-02-21 15:13:12 +01:00
|
|
|
void removeCharge(coordinate x, coordinate y);
|
2020-02-25 17:53:57 +01:00
|
|
|
|
|
|
|
/// Set new map for the level
|
|
|
|
void setMap(const Map& new_map);
|
2020-02-19 18:50:09 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // LEVEL_H
|