Matrix now just does the dumping but I need to make this more formal I think.

This commit is contained in:
Zed A. Shaw 2024-12-05 09:17:30 -05:00
parent eb0ca38e30
commit 56b26e1c4a
9 changed files with 44 additions and 33 deletions

25
map.cpp
View file

@ -5,30 +5,11 @@
#include <array>
#include <fmt/core.h>
#include <utility>
#include "matrix.hpp"
using std::vector, std::pair;
using namespace fmt;
void dump_map(const std::string &msg, Matrix &map, int show_x, int show_y) {
println("----------------- {}", msg);
for(size_t y = 0; y < map.size(); y++) {
for(size_t x = 0; x < map[y].size(); x++) {
int col = map[y][x];
if(int(x) == show_x && int(y) == show_y) {
print("{:x}<", col);
} else if(col == WALL_PATH_LIMIT) {
print("# ");
} else if(col > 15) {
print("* ");
} else {
print("{:x} ", col);
}
}
print("\n");
}
}
Map::Map(size_t width, size_t height) :
$width(width),
$height(height),
@ -73,8 +54,8 @@ bool Map::iswall(size_t x, size_t y) {
}
void Map::dump(int show_x, int show_y) {
dump_map("WALLS", walls(), show_x, show_y);
dump_map("PATHS", paths(), show_x, show_y);
matrix_dump("WALLS", walls(), show_x, show_y);
matrix_dump("PATHS", paths(), show_x, show_y);
}
bool Map::can_move(Point move_to) {