Post

 Resources 

Console

Home | Profile | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 VBGamer
 VBGamer
 Efficient ZOrdering
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sdw
Warrior

USA
160 Posts

Posted - Jan 18 2004 :  11:25:52 AM  Show Profile  Visit sdw's Homepage  Click to see sdw's MSN Messenger address  Reply with Quote
I basically need a link to a turorial or good explanation on how to achieve efficient ZOrdering. I have some ideas, but I thought it wise to make sure there is no simple method of doing it before I go and butcher my code.

Btw, yes I've searched over the net but havn't found any good tutorials.

sdw
Warrior

USA
160 Posts

Posted - Feb 03 2004 :  7:23:46 PM  Show Profile  Visit sdw's Homepage  Click to see sdw's MSN Messenger address  Reply with Quote
Was this a stupid question or what?

My original idea was to make a collection that stores data for drawing to the screen. So instead of drawing each sprite after all the calculations are made and new positions are updated, it just adds some data to this new collection about how to draw the sprite. Then before DD flips I call some sub which arranges the data from least to greatest according to the Y value for each chunk of data. After all of the sorting is done, it then blits everything from the top to bottom, making sprites with higher Y values drawn over top other sprites with a lesser Y value, thus making a zordering effect.

I have not tried this yet because I think it will take to much time to do and cut down on my fps. Would this be alright to try or are there more efficient methods of going about this?

Go to Top of Page

Krazex
Neophyte

7 Posts

Posted - Feb 09 2004 :  03:08:47 AM  Show Profile  Visit Krazex's Homepage  Reply with Quote
Make a draw array of units visible on screen, then boubble sort one character each frame.
Fast and effective.
Go to Top of Page

sdw
Warrior

USA
160 Posts

Posted - Feb 09 2004 :  09:26:53 AM  Show Profile  Visit sdw's Homepage  Click to see sdw's MSN Messenger address  Reply with Quote
Ok, I see what you're saying. Could the array be a UDT with info on how to draw the character? Then the bouble sorting sorts the array from least Y value to greatest Y value then blits them in that order? But I don't really understand why to sort only one character each frame. Could maybe an example be supplied?
Go to Top of Page

Krazex
Neophyte

7 Posts

Posted - Feb 09 2004 :  2:42:37 PM  Show Profile  Visit Krazex's Homepage  Reply with Quote
You should only add refrence numbers in the array to make the sorting as fast as possible.
Usually a app runns at about 60 fps which means you would have to have more then 30 characters to really notice that you only sort one each frame, and sorting one each frame is the absolute fastest way. And if there should be more characters on each frame add a if for it and sort 2 characters each frame.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
VBGamer © Go To Top Of Page
This page was generated in 0.12 seconds. Snitz Forums 2000

Copyright © 2002 - 2004 Eric Coleman, Peter Kuchnio , et. al.