Sorry about the quality of the video, forgot to lower the resolution of OBS before I started recording, so everything is pretty squished up.
Finally got all the draw order stuff done. Along the way I also made a number of graphical improvements and fixed up the particle system in a couple ways, so overall the game is looking much better.
The most important change out of these is the alterations to the order in which things are drawn. Previously everything just had a set draw order based on their position in memory, which was of course a terrible idea.
In the above picture, that glaive should really be drawn inside the sack, instead of on top of it. The previous draw system didn’t really have a way to work around this without some heavy spaghetti code, so I decided to rewrite the system with a red black tree. Now, each graphical element is added to the tree and automatically sorted to the correct draw order based on its height. Packaged with this element is a function that can then later be called to draw it. Once everything is added, the tree is traversed in order, drawing the element at each point.
Developing the tree and making it function with the rest of the code took around a week and a half, which is why I haven’t posted in such a long time. It should be worth it though, I’m not going to have to look at this kind of back end stuff for a long time.
I’ve also greatly improved the way the sacks are drawn, there is now much more perspective on the side of the sack, and it has a lot more depth, instead of the flat 2d pumpkin that it used to be.
The shadows have been improved significantly so that they actually draw like shadows instead of overlapping black goo. Ribbons now have shadows as well, and stay attached to their master when they become particles (in the top right you can see a ribbon attached to a chain). I was going to implement a gaussian blur for the shadows, but it turned out to be quite a bit more complex than the simple shaders I’ve created in the past so I’ll leave that for a later update. One other thing worth mentioning is that particles now stay within the bounds of the map and actually collide with the walls, instead of flying off into the infinite beyond.
So yeah, that’s my progress since my last post. I’m thinking I’ll start working on more of a user friendly interface, i.e. a start menu and more noticeable score board, after I fix up some last remaining graphical stuff. Currently there’s a lack of distinction between the foreground and the background, for instance in the picture above, it’s difficult to tell which weapons are being swung by the players and which are lying harmlessly on the ground.
If any of you want to see the source code for how I did the red black tree, perhaps if you’re interested in implementing a similar system, feel free to ask and I’ll upload it. Be aware that it’s written in lua though, so if you’re not familiar with that language it might be a little hard to understand.