Dividing Wall Fixed!
#PanicRoom Day 096
#100DaysOfGameDev R2D61
#100DaysOfCode R2D61
I finally fixed the wall build issue! After about a week of trying to figure out why my Aa room would only successfully split on the left side of the House and not the right side, I determined the source of my ire. And, of course, it was a stupid-easy fix in one line of code dealing with a particular variable. Isn’t that always the way?
When I was determining that the room should be split I was calling the BuildWall method and giving it the following information:
BuildWall(false, startX, wallLocation, roomWidth, “Single”, “Divider”);
This was working on the left side of the House because startX was 0 and roomWidth was whatever it was, so a wall was being built from 0 across to the width of the room. But, on the right side of the House startX was a much higher number, bigger than the width of the room, say 50 for example. If the room was only 20 squares wide then it was trying to build a wall from column 50 back to column 20, which was a negative value hence no wall.
To fix this and get my walls built properly all I had to do was add startX + roomWidth as my BuildWall endpoint and that would make it work no matter where it was called from (i.e. 0 to 0 + 20 or 50 to 50 + 20). Such a simple remedy, but so much time spent agonizing over where the problem was.
I’m glad to have finally solved this issue and it’s absolutely wonderful to see my House working the way I want it to up to this point. It also mean I can (finally) move on!
Sidenote: I also tweaked out my wall-building calculations so they no longer create overlapping wall pieces over existing exterior or hallway walls by starting one square later and ending one square earlier. I also noticed my references to room block origins started at square 0,0 when, in fact, my grid system actually starts with square 1,1. This was fixed as well to tighten things up.