forums

TNT Basic Forums > Programming Q&A
Sprite Priorities
< Last Thread     Next Thread >
Author
Thread        Post A Reply

10-14-2003 14:38

Posted by:
Miles

Location:
Australia

Click Here to Email Miles   Find more posts by Miles

Ok I'm not sure if this is a problem with TNT or it's just that I'm not going about this the right way, but I seem to have absolutely no control over which sprites appear over other sprites during TNT games.

Most of the time the sprites seem to appear in the order of their indexes, but then they often switch mid-program.

I've tryed putting 'Set Sprite Priority' before the 'Sprite ... ", after, before AND after, before the 'Draw Frame', at the start of the program and every frame, but to no avail. The sprites flop haphazardly over each other, randomly shuffling once every minute or so. They seem completely obvilious to their supposed priorities.

10-14-2003 15:11

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

you must use set sprite priority.

e.g.

while true

sprite 1,x,y,image
set sprite priority 1,100

sprite 2,x2,y2,image2
set sprite priority 2,50

sprite 3,x3,y3,image2

draw frame
wend

Sprite 3 will be under sprite 2, sprite 2 will be under sprite 1. I hope this helps.

10-14-2003 19:02

Posted by:
MapMaker

Location:
Edmonton, Alberta (Canada)

Click Here to Email MapMaker   Find more posts by MapMaker

And if that what you were doing....

I have no clue, but I have also run into similar problems sometimes. I re-arranged the code, and then it usually worked fine, but I never found out what caused it. (Might be a bug or somethng)

Sorry.

10-15-2003 00:19

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

If you're using variables for the "set sprite priority"s check to make sure that the variables don't change their value. And make sure that you aren't giving the sprites the same priorities of course. Other then that I don't know what could be wrong.

If you can post your code I can look at it.

10-15-2003 06:10

Posted by:
Miles

Location:
Australia

Click Here to Email Miles   Find more posts by Miles

Well, I definitely don't use variables for sprite priorities, and although it says in the help file that negative numbers are OK as sprite priorities, i've tried without negative numbers too, and that didn't change anything.

the only limited success i've had is by putting the 'Set Sprite Priority' before 'Draw Frame', making it re-set the sprite priorities EVERY frame, and oddly enough that seemed to work for about 20 seconds... and then all the sprite priorities randomised again...

the only thing i could possibly think of which might be the problem is: Does EVERY sprite require a unique sprite priority?

10-15-2003 06:25

Posted by:
Miles

Location:
Australia

Click Here to Email Miles   Find more posts by Miles

OK. I am beginning to seriously doubt it's a problem with my code. I think it's either something wrong with my computer or with TNT. I just tried writing a really simple program...

***
Graphics mode 640,480
Load Images 128

set sprite priority 1,50
Sprite 1,50,50,0
set sprite priority 1,100
Sprite 2,50,50,1

Draw Frame
while not mouse button
wend
***

and no matter what i declare the Sprite Priorities to be, sprite 1 ALWAYS appears in front of sprite 2.

even if i change sprite 1 to be sprite 3 (and, obviously, change the set sprite priority command to 3), that particular image always, without fail, appears in front of the other one. for some reason, TNT on my computer seems to rely of the index of the image in the image bank (like 0, 1, 2 etc) to decide who goes on top. no matter what image resides in index 0 and 1 of image bank 128, image 0 always gets drawn on top.

now this is weird, but at least i can use this knowledge to get my sprites drawn correctly.

10-15-2003 22:33

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

I experienced similar trouble too. I rearranged the code and it fixed it but I never knew why. I'm pretty sure there is a bug somewhere. I remember someonesaying the priority system going down if you set a sprite to the same value it is already...

10-15-2003 22:56

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

Umm...

quote:
set sprite priority 1,50
Sprite 1,50,50,0
set sprite priority 1,100
Sprite 2,50,50,1

You set sprite 1's priority twice but didn't set sprite 2's.

I think that might make a difference :)

10-16-2003 02:25

Posted by:
Miles

Location:
Australia

Click Here to Email Miles   Find more posts by Miles

Oops...

lol, yep, it did. ^_^;;

well, that typed out correctly, the test actually did work... so i guess i've made a mistake somewhere in my game code, but i cannot figure out what....

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.