|  | 
 Howdy, before we begin we need to cover some basic information on Zordering. What is Zordering? We all know that images we draw have an X and Y position. X being horizontal, and Y being vertical. So whats Z, Zertical? Ok, cheesey jokes aside. Z is your Depth, or distance. 
 This is where you step in. You have to "emulate" the Z position. Usually by moving the sprite up and down, creates the illusion of moving it farther and closer to the "camera". So, in this example, something with a lesser Z position will be farther back, and something with a greater Z position will be closer. 
 Here it is. We are going to create a "player", and some "boxes". The player moves around, and the boxes are static. All have an X and Z position. So lets set it all up. 
 Let me explain the types, and how we will use them. The Type 'Img' is be the core of how we arrange the images, this way they get drawed to the buffer in the correct order (farthest behind closest). 'Box' is our boxes, nothing special. 
 Above we create 10 boxes at random positions, so we can see whats going on. Now we make the variables that will track our players position. 
 Use the arrow keys to move our player around. Notice how the up and down keys change the Z positions. 
 Now we create an Img, this is our player (class=0 is a player). Then we create an image for each one of our boxes. We cycle through all the prevouis Images, and insert the new Image in the proper place (relative to Z positions), Basically, building the Images around the player. 
 Now we can just draw them as we loop through the type. Hope this explained the Dynamic Zordering method, there are more methods, but this seems to reduce the amount of Looping required, and is most accurate. If this method doesn't please you, look into using an Algorithm (like QuickSort). 
 If you notice anything wrong in this tutorial, please post it in the discussion, or email me at nullmind@attbi.com. 
 For a printable copy of this article, please click HERE. 
 This site is Copyright© 2000-2004, BlitzCoder. All rights reserved.   |