diff --git a/assets/map_tiles.png b/assets/map_tiles.png index aec7e89..dcf893e 100644 Binary files a/assets/map_tiles.png and b/assets/map_tiles.png differ diff --git a/assets/tiles.json b/assets/tiles.json index 0728c7c..05fda6d 100644 --- a/assets/tiles.json +++ b/assets/tiles.json @@ -5,6 +5,8 @@ "display": 10398, "ceiling": "ceiling_black", "light": 0, + "foreground": [40, 40, 40], + "background": [10, 10, 10], "id": 0 }, "wall_plain": { @@ -12,6 +14,8 @@ "collision": true, "display": 9608, "light": 0, + "foreground": [100, 100, 100], + "background": [10, 10, 10], "id": 1 }, "wall_moss": { @@ -19,6 +23,8 @@ "collision": true, "display": 8820, "light": 20, + "foreground": [150, 255, 150], + "background": [10, 10, 10], "id": 2 }, "ceiling_black": { @@ -26,6 +32,8 @@ "collision": false, "display": 35, "light": 0, + "foreground": [150, 150, 150], + "background": [10, 10, 10], "id": 4 }, "lava_floor": { @@ -34,6 +42,8 @@ "display": 35, "ceiling": "ceiling_black", "light": 20, + "foreground": [255, 0, 0], + "background": [10, 10, 10], "id": 5 }, "gray_stone_floor_light": { @@ -42,6 +52,8 @@ "display": 35, "ceiling": "ceiling_blue_light", "light": 40, + "foreground": [150, 150, 150], + "background": [10, 10, 10], "id": 6 }, "ceiling_blue_light": { @@ -49,6 +61,8 @@ "collision": false, "display": 35, "light": 0, + "foreground": [150, 150, 150], + "background": [10, 10, 10], "id": 7 }, "wood_wall": { @@ -56,6 +70,8 @@ "collision": false, "display": 35, "light": 0, + "foreground": [250, 250, 150], + "background": [10, 10, 10], "id": 8 } } diff --git a/tests/map.cpp b/tests/map.cpp index 5ebb1e2..750f7d0 100644 --- a/tests/map.cpp +++ b/tests/map.cpp @@ -121,7 +121,7 @@ TEST_CASE("map image test", "[map-sprite]") { auto coords = sprite_coord.at(display); sf::IntRect square{coords, {size.x, size.y}}; sf::Sprite sprite{map_sprites, square}; - sprite.setColor({150,150,150,255}); + // sprite.setColor({150,150,150,255}); sprite.setPosition({float(it.x * size.x), float(it.y * size.y)}); render.draw(sprite); } diff --git a/tools/icongen.cpp b/tools/icongen.cpp index a06bb7a..1bc62cc 100644 --- a/tools/icongen.cpp +++ b/tools/icongen.cpp @@ -25,6 +25,7 @@ using BoolGrid = Base; struct MapConfig { MapGrid map = make(TILE_COUNT, TILE_COUNT); BoolGrid centered = make(TILE_COUNT, TILE_COUNT); + std::unordered_map colors; each_row_t it{map}; }; @@ -124,7 +125,7 @@ struct MapTileBuilder { sprite.setPosition(cell_pos); } - sprite.setColor(DEFAULT_COLOR); + sprite.setColor(config.colors[display_char]); $render->draw(sprite); } @@ -160,8 +161,18 @@ void load_config(MapConfig& config, bool is_centered, std::string path, std::fun for(auto [key, val] : tiles.json().items()) { config.it.next(); - config.map[config.it.y][config.it.x] = finder(val); + auto display = finder(val); + config.map[config.it.y][config.it.x] = display; config.centered[config.it.y][config.it.x] = is_centered; + + if(val.contains("foreground")) { + auto fg_color = val["foreground"]; + sf::Color fg{fg_color[0], fg_color[1], fg_color[2]}; + config.colors.insert_or_assign(display, fg); + } else { + sf::Color fg{255, 100, 100}; + config.colors.insert_or_assign(display, fg); + } } }