The raycaster can now pair a floor with a ceiling tile and to demonstrate this I have a blue light that shines on to a stone floor. I also played with just pixelating a regular image rather than painting it and honestly it looks better in a lot of ways.

This commit is contained in:
Zed A. Shaw 2025-05-26 13:59:26 -04:00
parent e015652f4c
commit 931d9493d2
11 changed files with 50 additions and 39 deletions

View file

@ -27,16 +27,15 @@ namespace textures {
TMGR.sprite_textures.try_emplace(name, sprite, texture);
}
TMGR.floor = load_image(assets["sprites"]["floor"]["path"]);
TMGR.ceiling = load_image(assets["sprites"]["ceiling"]["path"]);
}
void load_tiles() {
Config assets("assets/tiles.json");
auto &tiles = assets.json();
TMGR.surfaces.resize(tiles.size());
TMGR.tile_set.resize(tiles.size());
TMGR.ceilings.resize(tiles.size());
TMGR.map_tile_set.resize(tiles.size());
for(auto &el : tiles.items()) {
auto &config = el.value();
@ -45,11 +44,22 @@ namespace textures {
if(surface_i >= tiles.size()) {
TMGR.surfaces.resize(surface_i + 1);
TMGR.tile_set.resize(surface_i + 1);
TMGR.ceilings.resize(surface_i + 1);
TMGR.map_tile_set.resize(surface_i + 1);
}
TMGR.tile_set[surface_i] = config["display"];
TMGR.map_tile_set[surface_i] = config["display"];
TMGR.surfaces[surface_i] = load_image(texture_fname);
// NOTE: ceilings defaults to 0 which is floor texture so only need to update
if(config.contains("ceiling")) {
const std::string& name = config["ceiling"];
dbc::check(tiles.contains(name), fmt::format("invalid ceiling name {} in tile config {}", name, (std::string)el.key()));
auto& ceiling = tiles[name];
TMGR.ceilings[surface_i] = ceiling["id"];
}
}
}
@ -83,19 +93,16 @@ namespace textures {
return texture;
}
std::vector<wchar_t>& get_tile_set() {
return TMGR.tile_set;
std::vector<wchar_t>& get_map_tile_set() {
return TMGR.map_tile_set;
}
const uint32_t* get_surface(size_t num) {
return (const uint32_t *)TMGR.surfaces[num].getPixelsPtr();
}
const uint32_t* get_floor() {
return (const uint32_t *)TMGR.floor.getPixelsPtr();
}
const uint32_t* get_ceiling() {
return (const uint32_t *)TMGR.ceiling.getPixelsPtr();
const uint32_t* get_ceiling(size_t num) {
size_t ceiling_num = TMGR.ceilings[num];
return (const uint32_t *)TMGR.surfaces[ceiling_num].getPixelsPtr();
}
};