Sunday, June 9, 2024

Let there be Light!

I wrote a good bunch of code. Not like a super lot, but you know, more than a bit. And it should have created a rudimentary party light to see as you wander about. And I launched the app, and... nada. I sat there pondering for a while, maybe the light isn't showing cause it's too bright? tweaked some other settings.... nada. Perhaps the zones aren't working properly... check, code, launch... nada.

I could keep this text-based adventure going on, but the short version is that I spend a good few hours trying to work out why lighting had completely stopped working. It for all intents and purposes, very much seemed to be working, doing all the calculations and registering lights properly, but somehow not rendering them in the end. Eventually found the change I'd made in the code at some point. Trying to save resources, I had tried to reuse a bitmap by clearing the contents rather than creating a new one. When I went back to my old code, it worked fine.

Right, so lighting was finally working again. Suddenly my party light was functioning the way I thought it should be. Sweet. Now to extend that to individual characters and monsters. Some pokery-jiggery later, I'd managed to have each character and monster holding a makeshift light... and going from there to rendering it all actually wasn't that long a step. My graphics engine was reasonably happy taking in the extra inputs and just plodding along.

It's early days, and everyone literally has the same hard-coded light, but the good news is that I can add in lights easily enough, render them in the right places and the engine is happy and keeps up when the camera is moved to a different character and so on. Is it perfect? Hell no. The framerate dropped down to 25, which is lower than I'd like it to be, and lights still aren't truly in the same granularity as the world really is. But you know what... it works. I'll take that win for now.

With things working nicely, it should mean that when I get to having permanent effects in locations, I'll be able to drop in a light on a burning location dynamically, or flash up some extra lighting when casting a lightning bolt, or some other suchness.

No comments:

Post a Comment

Something something Cloud something

The last few days I've been really focused on getting the cloud setup done right. I've half purposefully set myself up on a clock by...