From d02dfbe7b405d29b85081781d6ffbb3fbe81a5ab Mon Sep 17 00:00:00 2001 From: dylanbenzi Date: Thu, 13 Nov 2025 14:09:00 -0500 Subject: [PATCH] add intersection tile logic to map --- src/MazeMap.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/MazeMap.cpp b/src/MazeMap.cpp index 39f7158..544bfe7 100644 --- a/src/MazeMap.cpp +++ b/src/MazeMap.cpp @@ -137,6 +137,23 @@ bool MazeMap::isLegalTile(sf::Vector2i tilePos) const { // y >= 0 && y < static_cast(height); //} +bool MazeMap::isIntersectionTile(sf::Vector2i tilePos) const { + // true if more than two surrounding tiles are not walls + + int surroundingMovementTiles = 0; + + // +x (right) + if (!isWall({tilePos.x + 1, tilePos.y})) surroundingMovementTiles++; + // -x (left) + if (!isWall({tilePos.x - 1, tilePos.y})) surroundingMovementTiles++; + // +y (down) + if (!isWall({tilePos.x, tilePos.y + 1})) surroundingMovementTiles++; + // -y (up) + if (!isWall({tilePos.x, tilePos.y - 1})) surroundingMovementTiles++; + + return surroundingMovementTiles > 2; +}; + void MazeMap::draw(sf::RenderTarget& target, sf::RenderStates states) const { if (!texture || !baseMazeSprite.has_value()) return;