I now have hacked in basic color for the wall tiles but not enemies and items.
This commit is contained in:
parent
b2d0b0ee4c
commit
b16ca3fd65
4 changed files with 30 additions and 3 deletions
|
@ -25,6 +25,7 @@ using BoolGrid = Base<bool>;
|
|||
struct MapConfig {
|
||||
MapGrid map = make<wchar_t>(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};
|
||||
};
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue