The next little game in the series where I make a fancy rogue game.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
roguish/map.hpp

65 lines
1.3 KiB

#pragma once
#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;
void dump_map(const std::string &msg, Matrix &map);
void add_neighbors(Matrix &closed, size_t j, size_t i);
class Map {
Matrix m_input_map;
Matrix m_walls;
Matrix m_paths;
std::vector<Room> m_rooms;
int m_limit = 0;
public:
// 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; }
Matrix& walls() { return m_walls; }
int limit() { return m_limit; }
size_t width() { return m_walls[0].size(); }
size_t height() { return m_walls.size(); }
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(Room &cur, int depth);
void dump();
};