Jank thoughts on using the dijk map to walk from door to door for tunnels.

This commit is contained in:
Zed A. Shaw 2024-09-28 18:15:00 -04:00
parent b100950877
commit a82944f55a
3 changed files with 49 additions and 33 deletions

View file

@ -12,6 +12,8 @@
#include <ftxui/dom/node.hpp> // for Render
#include <ftxui/screen/box.hpp> // for ftxui
#include <ftxui/component/component.hpp>
#include <ftxui/screen/color.hpp>
#include <fmt/core.h>
#include "map.hpp"
#include "dbc.hpp"
@ -31,10 +33,10 @@ int main() {
Matrix &input_map = game_map.input_map();
Matrix &walls = game_map.walls();
input_map[10][10] = 0;
// place character
// input_map[10][10] = 0;
auto map = Renderer([&] {
game_map.make_paths();
Matrix &result = game_map.paths();
for(size_t x = 0; x < result[0].size(); ++x) {
@ -43,11 +45,12 @@ int main() {
if(path == 1000) {
// it's a wall or unreachable, use the wall_map
const string tile = walls[y][x] == 1 ? "#" : ".";
c.DrawText(x*2, y*4, tile);
c.DrawText(x*2, y*4, tile, Color::Yellow);
} else {
// it's a path number, show it
const string tile = format("{}", path);
c.DrawText(x*2, y*4, tile);
Color color = path == 0 ? Color::Red : Color::GrayDark;
c.DrawText(x*2, y*4, tile, color);
}
}
}
@ -58,27 +61,23 @@ int main() {
return canvas(c);
});
while (true) {
auto document = hbox({
hflow(
vbox(
gauge(0.5) | border,
text("STATUS") | border
) | xflex_grow
),
separator(),
hbox(map->Render()),
}) | border;
auto document = hbox({
hflow(
vbox(
gauge(0.5) | border,
text("STATUS") | border
) | xflex_grow
),
separator(),
hbox(map->Render()),
}) | border;
auto screen = Screen::Create(Dimension::Full());
Render(screen, document);
auto screen = Screen::Create(Dimension::Full());
Render(screen, document);
std::cout << reset_position;
screen.Print();
reset_position = screen.ResetPosition();
std::this_thread::sleep_for(0.01s);
}
std::cout << reset_position;
screen.Print();
reset_position = screen.ResetPosition();
return 0;
}