2020-02-19 18:50:09 +01:00
|
|
|
#ifndef LEVEL_H
|
|
|
|
#define LEVEL_H
|
|
|
|
|
|
|
|
#include <array>
|
2020-03-15 02:33:39 +01:00
|
|
|
#include "cell.h"
|
2020-02-19 18:50:09 +01:00
|
|
|
|
2020-03-15 22:57:39 +01:00
|
|
|
const std::string default_file_name = "test_map";
|
2020-02-19 18:50:09 +01:00
|
|
|
|
2020-03-15 22:57:39 +01:00
|
|
|
using Row = std::vector<Cell *>;
|
|
|
|
using Map = std::vector<Row>;
|
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;
|
2020-03-15 16:02:37 +01:00
|
|
|
sf::Color color_ground;
|
2020-03-15 22:57:39 +01:00
|
|
|
size_t level_width, level_height;
|
|
|
|
std::array<Cell *, N_CELLS> default_cells;
|
|
|
|
|
|
|
|
void prepareCellInstances();
|
|
|
|
void readMap(std::ifstream &file);
|
2020-02-19 18:50:09 +01:00
|
|
|
|
|
|
|
public:
|
2020-03-15 22:57:39 +01:00
|
|
|
Level(const std::string &map_file = default_file_name);
|
|
|
|
~Level();
|
|
|
|
|
|
|
|
size_t width() const;
|
|
|
|
size_t height() const;
|
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
|
|
|
|
|
|
|
/// Replace a charge cell with a ground cell
|
2020-02-21 15:13:12 +01:00
|
|
|
void removeCharge(coordinate x, coordinate y);
|
2020-03-15 16:02:37 +01:00
|
|
|
|
|
|
|
/// Get default color for passable cells
|
|
|
|
sf::Color defaultGroundColor();
|
|
|
|
|
|
|
|
/// Set default color for passable cells
|
|
|
|
void setDefaultGroundColor(const sf::Color &color);
|
2020-02-19 18:50:09 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // LEVEL_H
|