Quote: "The built-in priority of sprites are confusing."
Natural sprite priority is by the image number used in the sprite. In the following code it creates 17 random sprite numbers using image numbers 1 to 17. It shows all the sprites partially over each other in a line. The mouse is sprite number 1000 using image number 17 at the start. At image number 17 it is above all the other sprites. Press the mouse button to randomly pick another image number. If the image number picked is 10 it'll be above sprites with image numbers 1 to 10 but under sprites with image numbers 11 to 17.
randomize timer()
` Create 17 sprites
for ImageNum=1 to 17
` Pick a random sprite number between 1 and 999
repeat
SpriteNum=rnd(998)+1
until sprite exist(SpriteNum)=0
` Create a box
ink rgb(rnd(255),rnd(255),rnd(255)),0
box 0,0,50,50
ink rgb(255,255,255),0
` Show sprite number on the box
center text 25,0,str$(SpriteNum)
` Show image number on the box
center text 25,30,str$(ImageNum)
` Grab the image
get image ImageNum,0,0,50,50,1
` Create the sprite
sprite SpriteNum,ImageNum*40-40,ImageNum*10,ImageNum
next ImageNum
hide mouse
` Set the mouse for the highest image number
MImage=17
tim=timer()
do
` Show the mouse
sprite 1000,mousex(),mousey(),MImage
` Check for spacebar
if mouseclick() and timer()>tim+200
` Pick a random image number
MImage=rnd(16)+1
` Reset timer
tim=timer()
endif
loop