From 6d7a944a7d4d01fea83d2a753baa09efde1e0bd4 Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Tue, 17 Mar 2026 12:40:31 -0400 Subject: [PATCH] Quick move into textures.cpp so I can work on the final form of wall to door mapping. --- src/game/worldbuilder.cpp | 12 +----------- src/graphics/textures.cpp | 7 +++++++ src/graphics/textures.hpp | 2 ++ 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/game/worldbuilder.cpp b/src/game/worldbuilder.cpp index d0875f1..c86cbd2 100644 --- a/src/game/worldbuilder.cpp +++ b/src/game/worldbuilder.cpp @@ -179,21 +179,11 @@ void WorldBuilder::place_doors(DinkyECS::World& world, GameConfig& config) { // note, we set this to WALL_VALUE so it renders as a wall but map.iswall will check if its a door for collision walls[door_at.y][door_at.x] = WALL_VALUE; - size_t moss_wall_id = textures::get_id("wall_moss"); - size_t plain_door_id = textures::get_id("door_plain"); - size_t moss_door_id = textures::get_id("door_moss_wall"); - for(matrix::compass it{tiles, door_at.x, door_at.y}; it.next();) { if(walls[it.y][it.x] == WALL_VALUE) { // found a wall near the door, and since doors always have n/s/e/w walls it should be the one to use size_t wall_id = tiles[it.y][it.x]; // this is wall to use - // change this to texture::door_for_wall(wall_id); - if(wall_id == moss_wall_id) { - tiles[door_at.y][door_at.x] = moss_door_id; - } else { - tiles[door_at.y][door_at.x] = plain_door_id; - } - + tiles[door_at.y][door_at.x] = textures::door_for_wall(wall_id); break; } } diff --git a/src/graphics/textures.cpp b/src/graphics/textures.cpp index 4853fc6..7e9d906 100644 --- a/src/graphics/textures.cpp +++ b/src/graphics/textures.cpp @@ -201,4 +201,11 @@ namespace textures { return TMGR.map_sprites.at(display); } + + size_t door_for_wall(size_t wall_id) { + size_t moss_wall_id = textures::get_id("wall_moss"); + size_t plain_door_id = textures::get_id("door_plain"); + size_t moss_door_id = textures::get_id("door_moss_wall"); + return wall_id == moss_wall_id ? moss_door_id : plain_door_id; + } }; diff --git a/src/graphics/textures.hpp b/src/graphics/textures.hpp index 1a799da..d3bceab 100644 --- a/src/graphics/textures.hpp +++ b/src/graphics/textures.hpp @@ -51,4 +51,6 @@ namespace textures { sf::Sprite& get_map_sprite(wchar_t display); size_t get_id(const std::string& name); + + size_t door_for_wall(size_t wall_id); }