Archived

This topic is now archived and is closed to further replies.

Help me with layering!

This topic is 6281 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

ok, my prototype right now renders tiles whole layers at a time e.g. render all terrain tiles then render all tree tiles and so on. This was adapted from Bracket''s 3d in 2d demo. the problem is with walls. How do I detect dynamically on run-time when to render a wall behind a sprite and when to render on top? I have a function that renders all the sprites so all the walls can only be either behind or in front of every sprite. I''ve thought of splitting the function into two so I could sandwich the wall in between but that gives rise to all sorts of other problems like how to determine which sprite should be on which of the two layers.... thanx in advance for any help.

Share this post


Link to post
Share on other sites
You better render all ur tiles from top to bottom with all layers like this

for x=0 to number of tiles per screen width
for y=0 to number of tile per screen height

if character x pos>x and character x else
draw walls
next
next

Share this post


Link to post
Share on other sites
Having a function to draw all your sprites is not going to work.

The way I keep perspective is to do the following:

All drawing order is done left to right, top to bottom.
1. Render all base tiles (ground)
2. For each tile - left to right top to down
render from your lowest z position to your heighest z position. Include objects, tiles, sprites in this list.

For example at tile position x = 10, y = 0, I get all objects, sprites and tiles (which are presorted by its height) and draw them inn order. This will guarantee walls are placed infront/behind other objects/sprites in the correct perspective.

There probably are other ways to eliminate overdraw and do sprites after the object (walls) layer has been drawn but I found that the cpu overhead of attemping this out weighs just blitting everything in the correct order.

Hope this helps.

Share this post


Link to post
Share on other sites