cirno-puzzle/src/level.h

48 lines
1.0 KiB
C++

#ifndef LEVEL_H
#define LEVEL_H
#include <array>
#include "cell.h"
const std::string default_file_name = "test_map";
using Row = std::vector<CellPtr>;
using Map = std::vector<Row>;
/// Abstraction over 2D array to quickly get access to level cells
class Level
{
private:
Map map;
sf::Color color_ground;
size_t level_width, level_height;
std::array<Cell *, N_CELLS> default_cells;
void prepareCellInstances();
void readMap(std::ifstream &file);
public:
Level(const std::string &map_file = default_file_name);
~Level();
size_t width() const;
size_t height() const;
/// Place a bridge cell
void placeBridge(coordinate x, coordinate y);
/// Get the 2D array of level map
Map& mapArray();
/// Replace a charge cell with a ground cell
void removeCharge(coordinate x, coordinate y);
/// Get default color for passable cells
sf::Color defaultGroundColor();
/// Set default color for passable cells
void setDefaultGroundColor(const sf::Color &color);
};
#endif // LEVEL_H