Results 1 to 6 of 6

Thread: [RESOLVED] [Dx7] Z ordering (Am I going insane?)

  1. #1

    Thread Starter
    Hyperactive Member singularis's Avatar
    Join Date
    Nov 2006
    Location
    Over There!
    Posts
    372

    Resolved [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?

    Controls:

    Player1: W = Up , S = Down, A = Left, D = Right
    Player2: Uparrow = Up,Leftarrow = left, Rightarrow = right, Downarrow = down
    Attached Files Attached Files
    If what I said was helpful, give me rep!

    My Complete Games: -- 2D Zone (Space Shooter game) || _2D Zone 2_ || Ninja Blob (2D platformer) || Dren (Co-op up to 4 player base defence game)

    My Projects: -- The Dread Engine (2D VB game Engine) || A* Path Finding


    An excellent site for learning DirectX7, 8 & 9 (for VB6, C# & VB.net) would be: directx4vb.vbgamer.com --- For my projects and games see: pieper.freehostia.com

  2. #2
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    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.

  3. #3

    Thread Starter
    Hyperactive Member singularis's Avatar
    Join Date
    Nov 2006
    Location
    Over There!
    Posts
    372

    Re: [Dx7] Z ordering (Am I going insane?)

    Did you even look at my code? Look at my rendering function
    If what I said was helpful, give me rep!

    My Complete Games: -- 2D Zone (Space Shooter game) || _2D Zone 2_ || Ninja Blob (2D platformer) || Dren (Co-op up to 4 player base defence game)

    My Projects: -- The Dread Engine (2D VB game Engine) || A* Path Finding


    An excellent site for learning DirectX7, 8 & 9 (for VB6, C# & VB.net) would be: directx4vb.vbgamer.com --- For my projects and games see: pieper.freehostia.com

  4. #4
    Hyperactive Member Fedhax's Avatar
    Join Date
    Aug 2006
    Posts
    293

    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.

  5. #5

    Thread Starter
    Hyperactive Member singularis's Avatar
    Join Date
    Nov 2006
    Location
    Over There!
    Posts
    372

    Re: [Dx7] Z ordering (Am I going insane?)

    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
    Last edited by singularis; Jan 8th, 2007 at 02:37 AM.
    If what I said was helpful, give me rep!

    My Complete Games: -- 2D Zone (Space Shooter game) || _2D Zone 2_ || Ninja Blob (2D platformer) || Dren (Co-op up to 4 player base defence game)

    My Projects: -- The Dread Engine (2D VB game Engine) || A* Path Finding


    An excellent site for learning DirectX7, 8 & 9 (for VB6, C# & VB.net) would be: directx4vb.vbgamer.com --- For my projects and games see: pieper.freehostia.com

  6. #6

    Thread Starter
    Hyperactive Member singularis's Avatar
    Join Date
    Nov 2006
    Location
    Over There!
    Posts
    372

    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
    If what I said was helpful, give me rep!

    My Complete Games: -- 2D Zone (Space Shooter game) || _2D Zone 2_ || Ninja Blob (2D platformer) || Dren (Co-op up to 4 player base defence game)

    My Projects: -- The Dread Engine (2D VB game Engine) || A* Path Finding


    An excellent site for learning DirectX7, 8 & 9 (for VB6, C# & VB.net) would be: directx4vb.vbgamer.com --- For my projects and games see: pieper.freehostia.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width