Original Post
I know that this topic has been brought up many times before, and that there are a number of "helpful" tutorials floating around the internet. However, even after reading through these, I still can't seem to figure out a fool-proof way of sorting my isometric sprites. At this point I am almost out of ideas, and I'm hoping that somebody here has experience with Isometric depth sorting and could point me in the right direction. Here are the things I have tried: "Z-buffering" --- All the sprites are piled into a list and each is assigned a "Z" value based on its actual x,y,z coordinates in 3D space. I have tried (x+y+z), (x*x + y*y + z*z), and sqrt(x*x, y*y, z*z) as calculations for the Z value. All of these work well for sorting a perfectly aligned grid of cubes --- however, when I have a player sprite that can move between tiles, these methods fail (i.e., the player is sometimes displayed behind tiles it is actually on top of, and vice-versa). X/Y/Z sorting --- I make three passes at the sprites, and sort them based on their positions in 3D space. I use a merge sort to do this. Comparisons are made according to the following rules: a.x + TILE_SIZE <= b.x ----> a is "greater" b.x + TILE_SIZE <= a.x ----> b is "greater" ELSE They are considered "equal" and the order of sprites is preserved --- so, all sprites that are not "overlapping" in X will be sorted in X --- then the same will be done for Y and Z until everything is sorted. This method works better than the first one. Unfortunately, it still fails in special cases where the player is "in between" two grid cells, causing nearby blocks to be considered "equal" to it and not sorted properly. Anybody have any ideas?
