1 Attachment(s)
[RESOLVED] [Dx7] Z ordering (Am I going insane?)
I have an unique problem. It seems I cannot Z order things properly with directdraw. I am using my own sorting algorithm to find in which order to draw the players in but they always seem to do strange things.
When player1 (Thing(0)) is above player2 (thing(1)), player1 seems to always be behind things and if player1 is below player2, player1 seems to always be in front of things?
My code is attached and works fine with one player but not with two players
Can anyone help me? :confused:
Controls:
Player1: W = Up , S = Down, A = Left, D = Right
Player2: Uparrow = Up,Leftarrow = left, Rightarrow = right, Downarrow = down
Re: [Dx7] Z ordering (Am I going insane?)
You needed to have a proper order of drawing the sprites. The ones behind in the background should be first while the foreground is last.
Re: [Dx7] Z ordering (Am I going insane?)
Did you even look at my code? Look at my rendering function
Re: [Dx7] Z ordering (Am I going insane?)
Quote:
Originally Posted by singularis
Did you even look at my code? Look at my rendering function
I have. DoOrdering isn't going to work the way you want it to work. Since you reset County (County as in a small regional area or Count of position due to its Y value?) each go around, there is a good chance that your z-order gets hosed for that first element. What kind of sort are you wanting/trying to use?
Also, you may be better of assigning an arbitrary z-order to each element in your "Things" array and then swap the values between objects depending on some arbitrary condition--such as .GetPosY + 70.
Re: [Dx7] Z ordering (Am I going insane?)
Quote:
Since you reset County (County as in a small regional area or Count of position due to its Y value?) each go around, there is a good chance that your z-order gets hosed for that first element.
Could you expand on that please, I do not understand. Why the first element?
EDIT: I have just seen this -> http://www.vbforums.com/showthread.php?t=444394
Re: [Dx7] Z ordering (Am I going insane?)
It turns out my sorting alogaritm was fine, the only problem was in my drawing function not drawing all the objects correctly so I changed it from this:
Code:
for i = 0 to 10
draw object(object(i).z)
next i
to this:
Code:
for i = 0 to 10
for c = 0 to 10
if c = object(i).z then draw object(i)
next c
next i