Advertisement

Help me with layering!

Started by October 03, 2000 05:08 PM
2 comments, last by epic709 24 years, 3 months ago
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.
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
Advertisement
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.

Thanx. I''ll try both and see what happens.

This topic is closed to new replies.

Advertisement