diff --git a/assets/tiles.json b/assets/tiles.json index 462e312..849ca8e 100644 --- a/assets/tiles.json +++ b/assets/tiles.json @@ -27,6 +27,6 @@ "WATER_TILE": { "foreground": [132, 200, 0], "background": [147, 220, 2], - "display":"\u224b" + "display":"\u098c" } } diff --git a/status.txt b/status.txt index 4f0e736..03caeaa 100644 --- a/status.txt +++ b/status.txt @@ -1,5 +1,6 @@ TODAY'S GOAL: +* Tile component needs to go, use the Tiles from the json. * Fire icon \u2034 * Water icon \u224b * Flame pillars icon \u2e3e diff --git a/systems.cpp b/systems.cpp index 0c93d80..f306f43 100644 --- a/systems.cpp +++ b/systems.cpp @@ -155,6 +155,7 @@ void System::collision(DinkyECS::World &world, Player &player) { // BUG: this is kind of massive, need to maybe rethink how systems are designed. I mean...can each system be a callable class instead? void System::draw_entities(DinkyECS::World &world, Map &game_map, const Matrix &lighting, ftxui::Canvas &canvas, const Point &cam_orig, size_t view_x, size_t view_y) { + auto &tiles = game_map.tiles(); world.query([&](const auto &ent, auto &pos, auto &tile) { if(pos.location.x >= cam_orig.x && pos.location.x <= cam_orig.x + view_x @@ -162,13 +163,12 @@ void System::draw_entities(DinkyECS::World &world, Map &game_map, const Matrix & Point loc = game_map.map_to_camera(pos.location, cam_orig); int light_value = lighting[pos.location.y][pos.location.x]; - - // BUG: foreground color needs to come from entity and background color from the surface they're on + const TileCell& cell = tiles.at(pos.location.x, pos.location.y); // the 2 and 4 are from ftxui::Canvas since it does a kind of "subpixel" drawing - canvas.DrawText(loc.x*2, loc.y*4, tile.chr, [light_value](auto &pixel) { + canvas.DrawText(loc.x*2, loc.y*4, tile.chr, [light_value, cell](auto &pixel) { pixel.foreground_color = Color::HSV(255, 200, light_value + 20); - pixel.background_color = Color::HSV(30, 20, light_value / 3); + pixel.background_color = Color::HSV(cell.bg_h, cell.bg_s, light_value / cell.bg_v); }); } }); diff --git a/worldbuilder.cpp b/worldbuilder.cpp index 25bef4b..39c99f9 100644 --- a/worldbuilder.cpp +++ b/worldbuilder.cpp @@ -144,7 +144,9 @@ void WorldBuilder::generate() { Point center = $map.place_entity(1); for(matrix::circle it{$map.$walls, center, 3}; it.next();) { for(int x = it.left; x < it.right; x++) { - $map.$tiles.set_tile(x, it.y, "WATER_TILE"); + if(!$map.iswall(x, it.y)) { + $map.$tiles.set_tile(x, it.y, "WATER_TILE"); + } } } }