|
|
@ -17,31 +17,21 @@ |
|
|
|
#include "dbc.hpp" |
|
|
|
#include "dbc.hpp" |
|
|
|
|
|
|
|
|
|
|
|
using std::string; |
|
|
|
using std::string; |
|
|
|
|
|
|
|
using namespace fmt; |
|
|
|
using namespace std::chrono_literals; |
|
|
|
using namespace std::chrono_literals; |
|
|
|
|
|
|
|
|
|
|
|
Matrix input = { |
|
|
|
|
|
|
|
{1,1,1,1,1,1,1,1,1,1,1,1}, |
|
|
|
|
|
|
|
{1,1,1,1,1,1,1,1,1,1,1,1}, |
|
|
|
|
|
|
|
{1,1,1,0,1,1,1,1,1,1,1,1}, |
|
|
|
|
|
|
|
{1,1,1,1,1,1,1,1,1,1,1,1}, |
|
|
|
|
|
|
|
{1,1,1,1,1,1,1,1,1,1,1,1}, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Matrix walls = { |
|
|
|
|
|
|
|
{1,1,1,1,1,1,1,1,1,1,1,1}, |
|
|
|
|
|
|
|
{1,0,0,0,0,1,1,0,0,0,0,1}, |
|
|
|
|
|
|
|
{1,0,0,0,0,0,0,0,0,1,0,1}, |
|
|
|
|
|
|
|
{1,0,0,0,0,1,1,0,0,1,0,1}, |
|
|
|
|
|
|
|
{1,1,1,1,1,1,1,1,1,1,1,1}, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main() { |
|
|
|
int main() { |
|
|
|
using namespace ftxui; |
|
|
|
using namespace ftxui; |
|
|
|
std::string reset_position; |
|
|
|
std::string reset_position; |
|
|
|
|
|
|
|
|
|
|
|
auto c = Canvas(150, 100); |
|
|
|
auto c = Canvas(150, 100); |
|
|
|
|
|
|
|
|
|
|
|
Map game_map = Map(input, walls, 1000); |
|
|
|
Map game_map(50, 20); |
|
|
|
|
|
|
|
game_map.generate(); |
|
|
|
|
|
|
|
Matrix &input_map = game_map.input_map(); |
|
|
|
|
|
|
|
Matrix &walls = game_map.walls(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
input_map[10][10] = 0; |
|
|
|
|
|
|
|
|
|
|
|
auto map = Renderer([&] { |
|
|
|
auto map = Renderer([&] { |
|
|
|
game_map.make_paths(); |
|
|
|
game_map.make_paths(); |
|
|
@ -49,15 +39,21 @@ int main() { |
|
|
|
|
|
|
|
|
|
|
|
for(size_t x = 0; x < result[0].size(); ++x) { |
|
|
|
for(size_t x = 0; x < result[0].size(); ++x) { |
|
|
|
for(size_t y = 0; y < result.size(); ++y) { |
|
|
|
for(size_t y = 0; y < result.size(); ++y) { |
|
|
|
auto val = result[y][x]; |
|
|
|
auto path = result[y][x]; |
|
|
|
const string tile = val == 1000 ? "#" : fmt::format("{}", result[y][x]); |
|
|
|
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); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// it's a path number, show it
|
|
|
|
|
|
|
|
const string tile = format("{}", path); |
|
|
|
|
|
|
|
c.DrawText(x*2, y*4, tile); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
c.DrawText(4*2, 3*4, "@", Color::Blue); |
|
|
|
// draw the character
|
|
|
|
|
|
|
|
c.DrawText(10*2, 10*4, "@", Color::Blue); |
|
|
|
|
|
|
|
|
|
|
|
return canvas(c) | border; |
|
|
|
return canvas(c) | border; |
|
|
|
}); |
|
|
|
}); |
|
|
|