So I have been thinking on how I am going to do my walls. No matter how I twist it, I have got to have additional sprites to visually show the verticalness of the level and walls. I am treating them as opaque obstacles, so I will have to do them as walls. I will try really hard to minimize the number of extra sprites needed. I have been down the path of trying to combine sprites borders and edges several times now. And it’s always an arduous journey. So I will take some of the previous lessons and try to apply them into this.
First, let me update my tile sprites to something contrasty that I can properly see where walls are and what parts I am changing:
I considered a bunch of different alternatives, all finicky and all work-intensive. The least painful way I decided to go with is to have them consist of two tiles — one for the side and one for the top. Basically, one is a vertical wall that the player is facing, and the other is the horizontal plane on top of the wall “outside the play area”. It’s hard to explain in words, but it will be clear in a few screenshots (if I want to avoid pasting screenshots from other games).
For now, I need to specify for wall tile definitions which of the two types they represent (the side bit or the top bit):
And that means I have two distinct tile definitions now:
Then I will spawn another wall tile above each wall tile that has nothing else above it:
I also need to reveal these tiles properly when the player sees them, my fog of war logic has to be adjusted to take into account when a tile is a side tile:
Now, I can give it a sprite:
And make the dungeon generator actually place the correct layout of side and top wall tiles. Side walls only appear when there is walkable tile “below”/”in front of” it:
This should make it clear what I mean to do with the walls. And this already adds a whole lot of verticality to my tiles with just a couple colors. But it’s not enough artwise (the floor and the top of the wall blend together, as they partly should). What I need is top wall tiles that always have an “edge” when there is an implied vertical drop/wall there and here are all the sprites I would need for that (lighter bit is the edge facing whatever side the “real” edge is):
Cutting these up into actual sprites yields 16 pieces (each green square is a sprite):
I will place these in the four corners of the tile if and as needed (here, green overlay shows the four possible sprites that could be in that corner – top, left, full corner (both adjacent neighbours), corner tip (diagonal neighbour)):
These all align to each other. That means, I can mix and match the pieces, making any of the possible combinations.
Yes, this is hell of a lot of pieces. But the artist (which is likely me, but we’ll see) only has to make 5 new sprites. The main sprite serves as the base for all the rest. And the other have some unique bits, but are all generally the same sort of wall edge feature. And they are already pre-aligned for spriting and to see how they transition. And 4 sprites is much better than over 50 sprites (which is how many unique combinations there theoretically are). I just have to do the tedious coding for this, and I rather do the coding than add to art requirements.
In fact, this is such a huge list, that I will have a special asset for extra top wall sprites only:
And the in-world object for the tile also needs to have additional sprite renderers that I enable when and if I need additional sprites:
Which means I have a special world object just for the top wall that has this extra geometry to use:
Now comes a lot of finicky hard-coding of all the cases where and how top wall pieces can meet edges of tiles. Of course, my first working attempt is a grandiose visual failure:
So much so that I need to improve my sprite selection editor and rename all the sprites, just so I can keep them organized and correctly assigned:
But after lots of tweaking and considering all the cases, I can successfully select the corner “pieces” for each top wall tile based on its surrounding tiles and thus edges. So they always form edges towards the side walls and towards floors:
Even though the floors and wall tops are nearly the same color value, the edge clearly defines their border, and that’s the main goal here. It is also fairly easy to set the camera background color to match the wall top color and make them blend seamlessly:
This was one of the more troublesome features, where I spent a lot of time finicking about. I wish this wasn’t even needed, because all this does is add additional “art troubles”. But I can’t get away with flat walls (every decent top-down shooter roguelite does them similarly, although I think my 2×2 piece algorithm is not exactly common). On the other hand, it took me a day to do this and last time it took me over a week just to figure out how all tile borders might work. I think I’ve definitely used that experience here.
I still have issues with this and the above screenshots conveniently omit them. But this has been a big feature, so I will discuss improving my dungeon layouts to account for narrow walls and doors and such in the next entry.