@Comrade Robski
Quote: "Isn't it just based on the order you call each sprite using the SPRITE command?"
That's what I thought, but once the sprite is called, that's it's permanent priority - even if you delete it and recall it.
(on a side note - I modified the lightning texture you posted for one of the challenges into a function and use it to strike lightning periodically in the background of a 3d scene - it's pretty cool)
@Obese87
A while ago someone asked how to write text on a sprite. While this isn't "technically" possible without creating the sprite from an image with text already on it, I wrote some demo code to show how it could be done. After writing the code, I realized that the same method could be used to change sprite priority (which sprite is on top). Basically, you keep the sprites invisible, update their positions and then paste them. The last one pasted has top priority. You have to manage your screen clears and refreshes though - but this method will also increase performance because it takes less processing power to paste a sprite image than it does to constantly show a sprite. Because you update the hidden sprite position, you can still check for sprite collision. Here's an example:
rem sprite with text and priority
rem by latch
sync on
sync rate 60
ink rgb(255,0,0),0
box 0,0,100,100
get image 1,0,0,101,101
sprite 1,100,100,1
hide sprite 1
ink rgb(0,0,255),0
box 1,1,48,48
get image 2,0,0,50,50
sprite 2,400,225,2
hide sprite 2
a$="This is an"
b$="Illusion of a"
c$="Sprite with"
d$="Text on it"
ink rgb(255,255,255),0
do
cls
x=x+1
y=200
inc change
inc between
if change=1 and between=20 then msg$=a$
if change=2 and between=20 then msg$=b$
if change=3 and between=20 then msg$=c$
if change=4 and between=20 then msg$=d$
if change > 4 then change=0
if between>20 then between=0
if x >= 500 then x=0
rem toggle sprite priority
text 0,20,"Press space to change priority"
if spacekey()>last_spacekey
spacekeytoggle=1-spacekeytoggle
endif
last_spacekey=spacekey()
if spacekeytoggle=1
center text screen width()/2,0,"BIG Square has priority"
paste sprite 2,400,225
endif
sprite 1,x,y,1
paste sprite 1,x,y
text x+1,y+40,msg$
if spacekeytoggle=0
center text screen width()/2,0,"LITTLE Square has priority"
paste sprite 2,400,225
endif
if sprite collision(1,2)=1 then text 0,0,"The Sprites are colliding!!"
sync
loop
Enjoy your day.