Saturday, December 16, 2023

Faire Hollow Dev Log #4 - Spaghetti Code

It's been a busy few weeks! I've spent these past weeks refactoring some "spaghetti code", based on things that I've been learning about the Godot engine. The overall impact is now that the code is quite a bit cleaner and less interdependent on itself: nodes have fewer dependencies on one another, and the code is overall less fragile. And I feel like I keep learning how to do things better!

Godot has a concept of "signals", which allow any single node or code snippet to send a global message to any other script that's listening, saying, "hey, something just happened!". Any code can subscribe to listen for those signals, without needing to worry about how or where they originated. This means, for example, that I can update the date label at the top of the screen whenever a signal is fired indicating that the date has changed... and it doesn't matter how the date changed.

But like all things in programming, it's been a bit of two-steps-forward/one-step-back: for example, I experimented with an add-on called StateCharts, to replace my homegrown state machine for the Player, handling input around moving in 8 directions and standing idle in 4 directions. Ultimately I ended up ripping StateCharts back out, because I realized it was adding a lot of bloat for something that was working just fine. So there went a solid week of after-hours work. But in the process I learned a lot about state machines!

Some other updates:

  • I've introduced a versioning system. (We're on version 0.0.2!)
  • I reimported many of my 2d assets and reorganized the file structure.
  • I am more strictly typing my variables and functions, to prevent future errors.
  • I updated the engine to Godot 4.2.

Finally, I want to give a shout-out to my collaborator, Ewan, my 8-year-old, who is my new art director 😁  He has created an animated pixel art butterfly, which is now in the game flying across the screen! Ewan has been learning about pixel art and using Aseprite, a pixel art editor. He's getting really good -- he has a natural eye for this stuff!



No comments:

Post a Comment

Faire Hollow Dev Log #11 - Official Trailer

I am thrilled to share the official trailer for Faire Hollow! This has been a month-long effort to create just the right combination and var...