Archived

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

darkbard

Getting the right drawing order

Recommended Posts

darkbard    122
Anyone can explain me which are the tecniques to draw layers in the right order??Someone said me to draw them from right to left, but I don''t understand how to implement it... tnx

Share this post


Link to post
Share on other sites
NeonGE    140
The Draw to left rendering order is the way to go, this means that you have to invert your rendering loop, something like this:


for(int i=LastVisibleTileX; i>=FirstVisibleTile; --i)
{
...
Render(Tile);
...
}


Hope this help


If God with me, Who against me?

Share this post


Link to post
Share on other sites
darkbard    122
ok, but what does it change??It''s not the same thing to draw layers from "top to bottom"??

My problem was in displaing sprites in right order on the screen, but it seems this method doesen''t work...probably because I don''t understand it very well...

If i got 2 layers:
the 1st with a tree
the 2nd with the player

and I want to display the player behind the tree but also the tree behind the player if it happens, how can I do??
I can''t change layers order because of I got other srites into my layers than should not be swapped at the same time...

Share this post


Link to post
Share on other sites
TANSTAAFL    1160
truth be told, the easiest way to get things drawn in the proper location regardless of the order in which you draw them is to use d3d as your renderer, and make use of a z-buffer.

Share this post


Link to post
Share on other sites
Xiol    122
From what you are saying, layer1 is the tiles and layer2 is the sprites. Correct?

When do you want to draw the tree over the player?
And when do you want to draw the player over the tree?

Like this?


( P = player, T = tree, - = regular tile )

1) Tree hides player if the player's position is above the tree

------
--P---
--T---
------
------


2) Player hides tree if the tree's position is above the player

------
--T---
--P---
------
------



Or do you mean when the player and tile are at the same location?
If so, which do you want on top?

Also, do you want to completely hide the player/tree?
Or have them "peak" through, so you can see parts of them?


[edited by - Xiol on March 19, 2003 2:48:38 AM]

[edited by - Xiol on March 19, 2003 2:49:47 AM]

Share this post


Link to post
Share on other sites
darkbard    122
Perhaps my problem is about sorting the sprites...now i got only 3 layers:
1st for tiles
2nd pro object and characters
3rd for roof and so on..

now I need to understand how can I manage this "simple" thing:
I got 3 arrays which rappresente my layers'' structure.

1st question: when I move my sprites in 2nd layer, I got to update also the array?In this way I can display the objects and the characters in right order..or may be I have to save the object position and sort an array of object by y coords??

I have to manage rightly the drawing order of my things, hideing a pice or a whole of an object when another is in front of it...

Probably my problem is in my code structure.

2nd question: What kind of structure do you use to manage layers??

tnx

Share this post


Link to post
Share on other sites