Using a 3/4th perspective, I'm trying to create a way to render cliffs where nothing is overlapped, and it creates an accurate representation of the elevation. This is a rough mockup of how it might look in-game:
The way the tile data is organized is by layer. Each elevation has a layer class which holds all of the ground data for that specific layer, and all unoccupied space is simply null in the array. I can't seem to come up with a way to render the data so it would look something like this. I've thought about rendering from highest to lowest elevation, the other way around, etc. All entailed a situation where something is getting overlapped that shouldn't be.
What's the best way to do this?
Answer
I suggest that you draw the top rows [on the screen] first, and build up from the ground, overwriting the higher rows as you draw those tiles (you'll have to traverse the upper layers as you do this, but that should be easy as the X and Y will remain unchanged), and do so until all rows are completely drawn for you.
You can even loop beyond the bottom and just draw other things that are higher up even though their corresponding ground tiles are off the screen (creating a sense of even more depth for your scenes as your players navigate in any direction).
Additionally, if alpha-blending (transparency) mode is support, and if your character is always positioned in the centre of the screen (e.g., because the background scrolls when the player's character moves), you could also use transparency effects (with alpha-blending) when drawing the tiles that would block the view of the character (so the player can see what's going on), and gradually reduce this transparency effect with each tile that is further away from the character (80% transparency for the blocking tile, 60% for the next ones, 40% for the ones outside of that, then 20% outside of that, and finally 0% for all the rest).
No comments:
Post a Comment