Brought over a bunch of code from the roguelike and now will use it to generate a random map.
This commit is contained in:
parent
8d3d3b4ec3
commit
2daa1c9bd5
59 changed files with 4303 additions and 411 deletions
46
tilemap.hpp
Normal file
46
tilemap.hpp
Normal file
|
@ -0,0 +1,46 @@
|
|||
#pragma once
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <fmt/core.h>
|
||||
#include "point.hpp"
|
||||
#include "matrix.hpp"
|
||||
#include "config.hpp"
|
||||
|
||||
struct TileCell {
|
||||
std::string display;
|
||||
uint8_t fg_h = 0;
|
||||
uint8_t fg_s = 0;
|
||||
uint8_t fg_v = 0;
|
||||
uint8_t bg_h = 0;
|
||||
uint8_t bg_s = 0;
|
||||
uint8_t bg_v = 0;
|
||||
};
|
||||
|
||||
typedef std::vector<TileCell> TileRow;
|
||||
typedef std::vector<TileRow> TileGrid;
|
||||
|
||||
class TileMap {
|
||||
public:
|
||||
Config $config;
|
||||
size_t $width;
|
||||
size_t $height;
|
||||
matrix::Matrix $tile_ids;
|
||||
TileGrid $display;
|
||||
|
||||
TileMap(size_t width, size_t height);
|
||||
|
||||
// disable copying
|
||||
TileMap(TileMap &map) = delete;
|
||||
|
||||
size_t width() { return $width; }
|
||||
size_t height() { return $height; }
|
||||
void load(matrix::Matrix &walls);
|
||||
const TileCell &at(size_t x, size_t y);
|
||||
void set_tile(size_t x, size_t y, std::string tile_name);
|
||||
std::vector<std::string> tile_names(bool collision);
|
||||
|
||||
void dump(int show_x=-1, int show_y=-1);
|
||||
bool INVARIANT();
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue