I now have hacked in basic color for the wall tiles but not enemies and items.

master
Zed A. Shaw 2 days ago
parent b2d0b0ee4c
commit b16ca3fd65
  1. BIN
      assets/map_tiles.png
  2. 16
      assets/tiles.json
  3. 2
      tests/map.cpp
  4. 15
      tools/icongen.cpp

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

@ -5,6 +5,8 @@
"display": 10398, "display": 10398,
"ceiling": "ceiling_black", "ceiling": "ceiling_black",
"light": 0, "light": 0,
"foreground": [40, 40, 40],
"background": [10, 10, 10],
"id": 0 "id": 0
}, },
"wall_plain": { "wall_plain": {
@ -12,6 +14,8 @@
"collision": true, "collision": true,
"display": 9608, "display": 9608,
"light": 0, "light": 0,
"foreground": [100, 100, 100],
"background": [10, 10, 10],
"id": 1 "id": 1
}, },
"wall_moss": { "wall_moss": {
@ -19,6 +23,8 @@
"collision": true, "collision": true,
"display": 8820, "display": 8820,
"light": 20, "light": 20,
"foreground": [150, 255, 150],
"background": [10, 10, 10],
"id": 2 "id": 2
}, },
"ceiling_black": { "ceiling_black": {
@ -26,6 +32,8 @@
"collision": false, "collision": false,
"display": 35, "display": 35,
"light": 0, "light": 0,
"foreground": [150, 150, 150],
"background": [10, 10, 10],
"id": 4 "id": 4
}, },
"lava_floor": { "lava_floor": {
@ -34,6 +42,8 @@
"display": 35, "display": 35,
"ceiling": "ceiling_black", "ceiling": "ceiling_black",
"light": 20, "light": 20,
"foreground": [255, 0, 0],
"background": [10, 10, 10],
"id": 5 "id": 5
}, },
"gray_stone_floor_light": { "gray_stone_floor_light": {
@ -42,6 +52,8 @@
"display": 35, "display": 35,
"ceiling": "ceiling_blue_light", "ceiling": "ceiling_blue_light",
"light": 40, "light": 40,
"foreground": [150, 150, 150],
"background": [10, 10, 10],
"id": 6 "id": 6
}, },
"ceiling_blue_light": { "ceiling_blue_light": {
@ -49,6 +61,8 @@
"collision": false, "collision": false,
"display": 35, "display": 35,
"light": 0, "light": 0,
"foreground": [150, 150, 150],
"background": [10, 10, 10],
"id": 7 "id": 7
}, },
"wood_wall": { "wood_wall": {
@ -56,6 +70,8 @@
"collision": false, "collision": false,
"display": 35, "display": 35,
"light": 0, "light": 0,
"foreground": [250, 250, 150],
"background": [10, 10, 10],
"id": 8 "id": 8
} }
} }

@ -121,7 +121,7 @@ TEST_CASE("map image test", "[map-sprite]") {
auto coords = sprite_coord.at(display); auto coords = sprite_coord.at(display);
sf::IntRect square{coords, {size.x, size.y}}; sf::IntRect square{coords, {size.x, size.y}};
sf::Sprite sprite{map_sprites, square}; 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)}); sprite.setPosition({float(it.x * size.x), float(it.y * size.y)});
render.draw(sprite); render.draw(sprite);
} }

@ -25,6 +25,7 @@ using BoolGrid = Base<bool>;
struct MapConfig { struct MapConfig {
MapGrid map = make<wchar_t>(TILE_COUNT, TILE_COUNT); MapGrid map = make<wchar_t>(TILE_COUNT, TILE_COUNT);
BoolGrid centered = make<bool>(TILE_COUNT, TILE_COUNT); BoolGrid centered = make<bool>(TILE_COUNT, TILE_COUNT);
std::unordered_map<wchar_t, sf::Color> colors;
each_row_t<MapGrid> it{map}; each_row_t<MapGrid> it{map};
}; };
@ -124,7 +125,7 @@ struct MapTileBuilder {
sprite.setPosition(cell_pos); sprite.setPosition(cell_pos);
} }
sprite.setColor(DEFAULT_COLOR); sprite.setColor(config.colors[display_char]);
$render->draw(sprite); $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()) { for(auto [key, val] : tiles.json().items()) {
config.it.next(); 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; 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);
}
} }
} }

Loading…
Cancel
Save