Random map gen is mostly working, now to clean it up.

This commit is contained in:
Zed A. Shaw 2024-09-29 22:36:13 -04:00
parent a82944f55a
commit 3a43324fa2
3 changed files with 139 additions and 35 deletions

View file

@ -28,35 +28,31 @@ int main() {
auto c = Canvas(60 * 2, 27 * 4);
Map game_map(60, 27);
Map game_map(50, 27);
game_map.generate();
Matrix &input_map = game_map.input_map();
Matrix &walls = game_map.walls();
// place character
// input_map[10][10] = 0;
auto map = Renderer([&] {
Matrix &result = game_map.paths();
Matrix &walls = game_map.walls();
for(size_t x = 0; x < result[0].size(); ++x) {
for(size_t y = 0; y < result.size(); ++y) {
auto path = result[y][x];
if(path == 1000) {
if(path == 1000 || walls[y][x] == 1) {
// it's a wall or unreachable, use the wall_map
const string tile = walls[y][x] == 1 ? "#" : ".";
c.DrawText(x*2, y*4, tile, Color::Yellow);
c.DrawText(x*2, y*4, tile, Color::GrayDark);
} else {
// it's a path number, show it
const string tile = format("{}", path);
Color color = path == 0 ? Color::Red : Color::GrayDark;
auto color = Color::Palette16(path % 7 + 1);
c.DrawText(x*2, y*4, tile, color);
}
}
}
// draw the character
c.DrawText(10*2, 10*4, "@", Color::Blue);
//c.DrawText(10*2, 10*4, "@", Color::Blue);
return canvas(c);
});