Earlier this week I finished chapter 4 alpha and sent it out for testing.
Next week I'm going to start working on chapter 5.
The good news is that I already have a good idea of what's going to happen in this chapter, who you are going to meet and most of the locations you are going to visit, since I gave it a lot of thought when fleshing out the story direction when I worked on chapter 4.
But still there is a lot of dialogue to write, puzzles to think of, art to do and all the other stuff.
Chapter 5 is going to be the biggest of all 6 chapters, so there's plenty to do.
I'm not sure how often I will update on my progress and how much I will be able to share without spoiling, but I'll try my best to be more present than I was when working on chapter 4.
Now let's talk about shadows!
I briefly wrote about the new shadows in my previous post and I want to expand on that.
The engine I'm using only offers a very simple basic shadow system, nothing I could really use for my purposes.
So I had to implement my own system from scratch and here is the breakdown of how it works:
First thing I needed to do was to create placeholder objects for the light sources. These objects are mainly used to get the X,Y position of the light source, in order to calculate the shadow direction, angle and opacity.
They also hold another variable for the type of light, far light or close light. Far lights are always rendered in a fixed direction and opacity, like sun shadows for example. And close lights are updated in real time, based on the distance and angle of the player from the lightsource.
Second phase was to create another instance of every shadow casting player, one instance for each light source and place them all on a new “shadow” layer, above the background layers and below the players layer.
These instances are all flipped upside down, are tinted fully black and follow the player's collision box object, same as the actual sprite of the actor.
The last phase was all about math. I admit I spent the majority of my high school years playing the guitar, so math is not my strong suit. But I'm a quick study and with a little help from Google I always manage to get things done.
Honestly I learned a lot more math from making games than from school.
So the math for setting the shadow opacity was fairly simple, since it's basically just the distance of the player from the light source.
But the mesh deformation was a little trickier. It took a few hours, grinding teeths and a little loss of hair, but I eventually got it done.
At least I thought so, but then I notice that when the player walks the other way, meaning the sprite is mirrored, the deformation is also mirrored, and skewed in the wrong way. So I had to have two different calculations, one that skews left and one that skews right based on the direction the player is facing.
Yada, yada, yada, here's the final in-game result:
It's still not perfect and I will tweak it more over time. Maybe also add more features like the strength/spread of the light source, or flickering/sine waving lights. But for now, I'm happy with the results.