z-ordering
BlitzMax Forums/BlitzMax Programming/z-ordering
| ||
Hey guys, if I want to add zordering to my existing framework can you say if this is the right way to go about? I've created a list called zlist. I've added two objects that are drawn to this list, overridden the compare method in the type where zlist is and where one of the objects is instanced from. I've called sortlist (zlist) in the main loop, to order based on the z values of the z fields ive added to the two types of the two different objects or can I only z-order objects of the same type? |
| ||
Hiya, You should be able to compare against different types, yes. In the overridden compare method you will have to cast to each object type that you want to compare with, although it's 'cleaner' to use a single basetype with the common fields and methods ( one of which is the Compare methodm using a cast of itself ) and extend your other types from that. Either way will work ok. Last edited 2013 |
| ||
You can also use a TMap, which will do a sort of dynamic sorting as you add objects. I don't know which is faster. |
| ||
hmm ok, I've kind of done things the cheat way, I am drawning first what I want down first. static background planets stars ships weapon graphics/effects in that order not that many more objects in the game, I guess 2d space games have it somewhat easy :) |
| ||
FYI, you could clear the depth buffer after step 2 if you find the 24-bit depth buffer doesn't give you the resolution you need for the size of your world. The Source Engine does this for rendering 3D backgrounds, so it can render things further away than it normally would be able to. |