I search speed algorithm sorter for paint

hello,

I search a speed sorted paint algorithm for my group of sprites.

have you a example or tips ?

thank you

Excuse me, but could you explain a little bit more in detail. That would help a lot.

ha sorry for my english.

is for paint one sprite on foreground or background of other sprites depending of the location of sprite on map.

in iso map this :

The Quicksort-algorithm is very fast (as the name lets you expect.), but i never testet out yet if its fast enough for sorting your Sprites each frame…

mbw

Seems like you have only few fixed positions where the sprites can be positioned, not on every single pixel?
Depending on the number of sprites and number of possible positions you may also try a bucketsort.

  1. If you only care for correct y-drawing and not for the way in whic they overlap in x direction, then create as many vectors/arraylists/arrays (what seems best) as you have positions in y and put them in there according to their y-coordinate and then draw each array. Time is 2*n for n sprites
  2. If your care for x-overlapping: make an 2dim array as big as your field. On each sorting set each element to null, then insert the sprites, then run linear through the field again and draw as needed. Time is 2*m+n (m number of fields/possible positions). If this is good really depends on the relative size of m to n. If you have few sprites but many fields it will be slower than a standrad sort.
  3. Or simpy use the Collection sort algorithm. Should be as fast as any handcrafted n*log n sort algorithm.