A sidebar with passing time
Next I wanted to work on a sidebar. Something to display stats – character name, time of day, status messages, all the normal stuff you get in a roguelike. Putting the actual sidebar together was easy – it’s just a bunch of UI canvas elements. What ended up being hard was properly coding in the motion of the sun and moons.
My problem is that I love astronomy and have a degree in astrophysics that I never get to use. This means that my data and tables for moonrise and moonset needed to be accurate. Given the light from one of the moons is deadly, it needed to be accurate to the smallest unit of time in the game – down to the minute.
While I could have put this information in a huge premade table, I decided to code the equations for moonphase, fraction of moon lit, and moonrise and moonset straight into the game. I think this is the best path, as I believe it takes less resource to run a simple mathematical equation than to constantly open a file or read entries from an array that has to be held in memory.
In the end, what I got working was a sidebar that lists the current time and shows which moons are up, what their phases are, and when the next moonrise or moonset for each moon is. To get this to work, I also had to code in some debug input commands to let me make time move forward so I could test things. This took weeks, but now it works!

The only other relevant point here is that as I was doing this, I realized other things that I needed to do. You can walk around the worldmap and have time progress. But given one of my moons is deadly, travel should halt at night on the worldmap while you hunker down away from moonlight. So consider the following scenario: Moving one tile is supposed to take 8 hours and it’s currently 4 pm, with the moon becoming deadly at 6 pm and not setting until 1 am. 4 pm + 8 hours = midnight, which is what the game currently calculates. What I’d like it to do is have the player use 2 of the 8 hours to get from 4pm to 6pm, then wait until 1 am for the moon to set, then do the other 6 hours of travel, not finishing until 7 am. I’ll need some way to indicate to the player why that extra time passes, but this is once again a problem for future me. What’s relevant now, though, is that instead of solving this extraneous problem NOW, I’m writing it down to solve it later, after my MVP is done.


