This implements base ambient lighting for tiles which helps with tiles like lava and ceiling lights.
This commit is contained in:
parent
74a1801069
commit
3dc70c3af6
11 changed files with 48 additions and 17 deletions
20
textures.cpp
20
textures.cpp
|
@ -29,13 +29,18 @@ namespace textures {
|
|||
}
|
||||
}
|
||||
|
||||
inline void resize_shit(size_t size) {
|
||||
TMGR.surfaces.resize(size);
|
||||
TMGR.ceilings.resize(size);
|
||||
TMGR.map_tile_set.resize(size);
|
||||
TMGR.ambient_light.resize(size);
|
||||
}
|
||||
|
||||
void load_tiles() {
|
||||
Config assets("assets/tiles.json");
|
||||
auto &tiles = assets.json();
|
||||
|
||||
TMGR.surfaces.resize(tiles.size());
|
||||
TMGR.ceilings.resize(tiles.size());
|
||||
TMGR.map_tile_set.resize(tiles.size());
|
||||
resize_shit(tiles.size());
|
||||
|
||||
for(auto &el : tiles.items()) {
|
||||
auto &config = el.value();
|
||||
|
@ -43,12 +48,11 @@ namespace textures {
|
|||
size_t surface_i = config["id"];
|
||||
|
||||
if(surface_i >= tiles.size()) {
|
||||
TMGR.surfaces.resize(surface_i + 1);
|
||||
TMGR.ceilings.resize(surface_i + 1);
|
||||
TMGR.map_tile_set.resize(surface_i + 1);
|
||||
resize_shit(surface_i + 1);
|
||||
}
|
||||
|
||||
TMGR.map_tile_set[surface_i] = config["display"];
|
||||
TMGR.ambient_light[surface_i] = config["light"];
|
||||
TMGR.surfaces[surface_i] = load_image(texture_fname);
|
||||
|
||||
// NOTE: ceilings defaults to 0 which is floor texture so only need to update
|
||||
|
@ -93,6 +97,10 @@ namespace textures {
|
|||
return texture;
|
||||
}
|
||||
|
||||
std::vector<int>& get_ambient_light() {
|
||||
return TMGR.ambient_light;
|
||||
}
|
||||
|
||||
std::vector<wchar_t>& get_map_tile_set() {
|
||||
return TMGR.map_tile_set;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue