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/matrix.cpp

57 lines
1.1 KiB

#include "matrix.hpp"
#include "constants.hpp"
#include <fmt/core.h>
using namespace fmt;
using matrix::Matrix;
namespace matrix {
each_cell::each_cell(Matrix &mat)
{
height = mat.size();
width = mat[0].size();
}
bool each_cell::next() {
x++;
x *= (x < width);
y = y + (x == 0);
return y < height;
}
each_row::each_row(Matrix &mat) :
$mat(mat)
{
height = $mat.size();
width = $mat[0].size();
}
bool each_row::next() {
x++;
x *= (x < width);
y = y + (x == 0);
row = x == width - 1;
cell = y < height ? $mat[y][x] : -1;
return y < height;
}
void dump(const std::string &msg, Matrix &map, int show_x, int show_y) {
println("----------------- {}", msg);
for(each_row it{map}; it.next();) {
if(int(it.x) == show_x && int(it.y) == show_y) {
print("{:x}<", it.cell);
} else if(it.cell == WALL_PATH_LIMIT) {
print("# ");
} else if(it.cell > 15) {
print("* ");
} else {
print("{:x} ", it.cell);
}
if(it.row) print("\n");
}
}
}