Refactoring Struggles

After some time spent playing around with some backgrounds and parallax, plus replacing that god-awful round enemy with something slightly less awful, I decided to sit down and refactor Nori's code before moving onto a release candidate for closed testing.

In my excitement early on, I had been throwing thing into Nori's physics process, and the code was getting a bit bloated. I also found that in a few areas, I was duplicating a lot of processes or relying on magic numbers. I wanted to clean all of that up, opt for an easier to read physics process and enumerate a state machine into her to better handle moving, jumping, and actions.

Doing this introduced a strange variety of issues, but mostly went pretty smoothly. I found handling animations became an odd struggle. For a long period, Nori was simply stuck in her Falling animation, which turned out to be an issue where the MoveState was never being checked for new animations – silly me! Another problem was that there were specific ways that I had been handling jumping and landing that required code to be executed in a specific order or within the physics process. For example, I was checking for the Jump key input directly within the physics process originally, but after moving it to the Unhandled Input call instead, a few pieces of code no longer worked. I had to pull those pieces out and find ways to integrate them into the function for processing the jump state. Not impossible, but a useful lesson to learn!

Overall, I've enjoyed the process greatly! Nori can now move, jump, fall, and swim all like she could before, but now operating on a better designed set of state machines. Adding new functionality will simply be an expansion of the existing state machines to facilitate those changes.

My next goal is to overhaul the Overworld programming, as it was definitely on the fly and could do for a real breakdown and optimization before I begin putting together real maps. Having both of those better optimized and refactored means I can focus more on adding features and content, rather than trying to constantly fix cobbled code.