RPG Project - Post 2
When I started this project I thought I'd go with a top down 3/4 view , figuring that it should be easier to do. I've spent the past two weeks fighting with what I though should've been some simple layering.
I had hoped to be able to quickly get a video going of a character walking around the game world. It didn't take long to get an old sprite up and modify the code I had from the platformer I was working on before to work for a top down sort of world. Fought with collisions a little bit but ended up with a few improvements to the code and generally feeling happy about progress. Then I set about fixing up a little display issue I was having layering tiles and my sprite.
To start, I was just painting the terrain tiles and then my old snark sprite right on top (I'll be using a different player character eventually). Which is fine for some general testing but I wanted to have it so that the snark could hide behind the walls a bit. So I add in the code to redraw the appropriate tiles and fringe pieces and I kinda got what I was hoping for.
But also quickly found that I wasn't redrawing all the pieces I needed to be.
I thought about the problem a bit.
- The lower fringe pieces need to be redrawn on top so the snark appears behind a wall.
- The left and right fringes need to be redrawn on top so that the snark appears to emerge from behind the wall.
- The upper fringes should not be redrawn so that the snark always appears on top.
When I coded for this I found that as I travel up through a 1 tile wide hallway, the snark is hidden by the left and right fringes. Not really a problem until he approaches a turn or dead end where the upper fringe is displayed. At that point you find yourself with the same sort of layering issues you see in the second picture above (sorry I don't have an image handy).
I think I went between redrawing and not redrawing the side fringes once or twice and was getting frustrated. I tried to remember what I've seen in games with a 3/4 view with this sort of hiding behind objects thing. I don't know if my memory isn't reliable enough or if I didn't Google hard enough but I couldn't really think of examples of what I'm trying to do. I could only think that if anything came close, you were probably able to hind behind a wall but you wouldn't be obscured by left and sides of fringes. Either your character is always drawn on top or the sprites are such that they will always fit between any corridor walls
with no fringe layering taking place.
After a few of tries at techniques I could think of, I ended up approaching the problem with acceptance that you won't be able to hide yourself as completely by a wall. You could walk behind a wall fringe but that fringe's depth is small enough that you don't end up walking down far enough to start worrying about the left and right side fringes. This means that the space that a wall tile takes up is effectively greater than 1 tile. This ends up with a just bit of a depth effect and means I don't have to figure out all my tiles again. In order for it to work right I also had to expand the collision rectangle a bit and track whether or not a character's move was successful or not. If the character is unable to move left or right as intended, he appears on top of the fringe pieces that he'd otherwise appear behind. So far, so good. At least, it's good with only 1 character to worry about.
I'm not really sure what completely hiding stuff behind walls would really add to game play anyway. That might be just a sour grapes thing, but other than looking kinda cool, what am I really going to do? Make chests you need to complete a quest impossible to find? Maybe hide such that they leap out and kill you with no chance to react? I'll take the little bit of appearance of depth I got out of it and leave it at that.
Gonna have to get a YouTube thing set up so I can link in the videos better. In the mean time, I'll have to add it to my gallery this way I guess.