Refactor into the class for more work.
This commit is contained in:
parent
04b16c75ad
commit
44f11d5ddd
2 changed files with 42 additions and 37 deletions
40
map.hpp
40
map.hpp
|
@ -2,12 +2,24 @@
|
|||
#include <vector>
|
||||
#include <utility>
|
||||
#include <string>
|
||||
#include <random>
|
||||
|
||||
struct Pair {
|
||||
size_t j = 0;
|
||||
size_t i = 0;
|
||||
};
|
||||
|
||||
struct Room;
|
||||
|
||||
struct Room {
|
||||
size_t x = 0;
|
||||
size_t y = 0;
|
||||
size_t width = 0;
|
||||
size_t height = 0;
|
||||
|
||||
std::vector<Room> next;
|
||||
};
|
||||
|
||||
typedef std::vector<Pair> PairList;
|
||||
typedef std::vector<int> MatrixRow;
|
||||
typedef std::vector<MatrixRow> Matrix;
|
||||
|
@ -22,7 +34,17 @@ class Map {
|
|||
int m_limit = 0;
|
||||
public:
|
||||
|
||||
void make_paths();
|
||||
// make explicit
|
||||
Map(Matrix input_map, Matrix walls_map, int limit) :
|
||||
m_input_map(input_map),
|
||||
m_walls(walls_map), m_limit(limit) {
|
||||
}
|
||||
|
||||
// make random
|
||||
Map(size_t width, size_t height);
|
||||
|
||||
// disable copying
|
||||
Map(Map &map) = delete;
|
||||
|
||||
Matrix& paths() { return m_paths; }
|
||||
Matrix& input_map() { return m_input_map; }
|
||||
|
@ -33,20 +55,14 @@ public:
|
|||
|
||||
void make_room(size_t origin_y, size_t origin_x, size_t width, size_t height);
|
||||
|
||||
void generate();
|
||||
void draw_map(Room &root);
|
||||
void make_paths();
|
||||
void partition_map(std::mt19937 &gen, Room &cur, int depth);
|
||||
|
||||
void dump() {
|
||||
dump_map("PATHS", m_paths);
|
||||
dump_map("WALLS", m_walls);
|
||||
dump_map("INPUT", m_input_map);
|
||||
}
|
||||
|
||||
void generate();
|
||||
|
||||
Map(Matrix input_map, Matrix walls_map, int limit) :
|
||||
m_input_map(input_map),
|
||||
m_walls(walls_map), m_limit(limit) {
|
||||
}
|
||||
|
||||
Map(size_t width, size_t height);
|
||||
|
||||
Map(Map &map) = delete;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue