tutsplus / Using-BSP-Trees-to-Generate-Game-Maps

http://gamedevelopment.tutsplus.com/tutorials/how-to-use-bsp-trees-to-generate-game-maps--gamedev-12268
BSD 2-Clause "Simplified" License
15 stars 6 forks source link

Same X coordinate? #2

Open mikechabot opened 4 years ago

mikechabot commented 4 years ago

Why is it that when creating the left and right children, you're assigning them all identical X positions? If you're splitting horizontally, I'm struggling to understand why the algorithm would assign the same x position to both children. Would they not be overlapping?

if (splitH)
{
    leftChild = new Leaf(x, y, width, split);
    rightChild = new Leaf(x, y + split, width, height - split);
}
else
{
    leftChild = new Leaf(x, y, split, height);
    rightChild = new Leaf(x + split, y, width - split, height);
}

https://github.com/tutsplus/Using-BSP-Trees-to-Generate-Game-Maps/blob/master/src/Leaf.as#L54