Floor Grids Fixed (Again)
#PanicRoom Day 078
#100DaysOfGameDev R2D43
#100DaysOfCode R2D43
When I identified that my Grid Overlays were out of alignment after changing my Sprite Pivots to better place all House Tiles I had hoped it would be a relatively easy fix by going in and adjusting some variables and calculations. I was half right.
On one hand my code is now set up in such a way that it is fairly easy to go in and make alterations, or even try out new things to see if they work, but the problem that was newly-evidenced was that it was going to take more than a few quick changes to get everything back on par again. Am I surprised at this point?
Because my Grid Overlay system was completely constructed around larger 2×2 Floor Grid Tiles, I had to make sweeping changes to how all lines and labels were calculated. The system now needed to be base around 1×1 House Grid Tiles, which is what I should have done from the beginning. Setting DrawHouseGrid was an easy fix in this case, but I had to pretty much re-do DrawFloorGrid. Changing the calculations for the line placement worked quickly, as did setting it up to produce the correct number of lines. The problem I wasn’t expecting, however, was the length of the lines due to the instance.transform.localScale formula. I that I had an easy fix for it, but (literally) came up short when I realized that an odd number of columns was causing undersized lines to be produced. To adjust for this I had to come up with a variable to modify columns and rows that only DrawFloorGrid would use so DrawHouseGrid could remain unaffected.
This worked, but then a NEW problem cropped up: overextended Floor Tiles. My intent is to have the number of rows and columns represent the exact footprint of the entire house. To this end my Floor Tile placement, as it stands, uses an odd number of either rows or columns as purchase to create another set of floor tiles. The problem with this is that floor tiles are 2×2 and creating another row/column on an odd number causes them to extend exactly 1 column or row beyond my intended limit.
To fix this I adjusted the code to ignore odd columns and rows for Floor Tile placement (and subsequent Floor Grid generation) and these odd rows/columns will then only have exterior rows on them thus filling out the entire House footprint. Grid Overlays are now working properly again with this fix.