REFACTOR REFACTOR REFACOTR - MARCH 2022

Lots of refactoring and bug fixes. I worked on adding doors to rooms, making sure they can only be placed on walls. I also added free-position sprite placement functionality, although as of today that functionality has been abandoned (at least for now, as its not longer needed). Originally doors were "free" placed on the walls between rooms. This was due to some limitations of the game engine at the time. Namely, a door had to invisibly occupy two tiles so it connected two rooms. Since I was already outputting walls where doors would be placed, and I didn't feel like making another SFML Vertex Array for tiles (for no good reason), I added free placement (although in reality it snapped to the position between two tiles). (At this point I should mention the game was purely top down, not tilted top down as it is today.)

I also started outputting error message to the screen. Having already added all the rules needed for zone/building/room placement, this was the next logical step. I also added an "address book" to the game. When a driveway is connected to a road, the building's address will be added to the address book. That way units will be able to path to buildings.

Did I mention I fixed bugs and refactored the code? A lot of that happened in March. I implemented individual room tile deletion, bottom bar updating on contextual right click, and WASD panning. Game engine tile rotation/mirroring was added, which was tricky because SFML does not have a way to rotate individual tiles in a vertex array (WHAT?!). I hacked my way to success here. You have to be familiar with SFML to understand this, but essentially I discovered that if you changed the ordering of the quad positions (as they are filled in), it rotates the tile! This required updating everything that touches the graphics, but at this point the game was probably less than 10,000 LOC.

I also worked on the path finding code some more. I also attempted to implement intersection based path finding (instead of edge nodes; e.g. there are four edge nodes in a four way intersection). I discovered this should be possible, and will drastically cut down on path storage creation time, but there are a handful of complicated edge cases I would have to hard code in (like doing a U-turn at a dead end, since only one node would exist instead of two). Eventually I set this aside. Way too complicated and not high priority.

Another part of the game I worked on was road placement. At this stage in the game I was hard coding every possible road combination, which was a painfully long task. My first goal when implementing a new system in my game is to just get it work. Then I go back and refactor and simplify the code, and figure out a way to make it scale-able without having to rewrite the existing code. Note that I had 1x1 and 2x2 road tiles at this point, and connecting them all in every possible (legal) configuration was a lot of work. They had to graphically (visually) connect, and graph...ically (logically) connect.

Due to some construction outside my apartment, followed by a head cold, I stalled all development in the second to last week of March. Having a nail gun go off all day outside your wall you does not create a conducive environment to work.

Published Date: 06/25/2022
Total Development Time: 4 months