> Every object gets a z-depth assigned. For the players the > zdpeth need to be set based on the tile they are at. This way > the players can walk 'around' the enviorment objects. For the > z-depth calculation I use the tile grid x and y plus the > width of the row, this generates an unique z-depth number and > makes sure that the higher the y, the bigger the z-depth , > thus objects appear infront of objects with a lower y index. > Here is the problem I am trying to figure out. If two movable > objects, or even three of them are at the same time on the > same tile, then the above described z-depth managing will > fail. How do I deal with that?
If this is possible in your game then you'll need to either store sub-tile positions and z-sort further on those (you could, for example, assign ten z-slots per tile to ensure that you have more space) or randomly choose one to be in front of the other (if there's only one position per tile, then it doesn't matter which one gets drawn in front). > > Then another question I have is this. Does every movable > object needs to check/swap z-depth on every frame. Wouldn't > that be to CPU intensive? Depends how you do it. If there's only a few movable objects, this shouldn't be particularly hard on the machine - Flash isn't the fastest thing in the world, but it's fast enough for that. However, you can optimise quite a bit by sub-sorting - if you know that object 1 is in the rear 16 tiles and object 2 is in the front 16 tiles, no need to check the z-order. Danny _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com