forums

TNT Basic Forums > Programming Q&A
Searching Arrays
< Last Thread     Next Thread >
Author
Thread        Post A Reply

03-03-2003 20:13

Posted by:
MapMaker

Location:
Edmonton, Alberta (Canada)

Click Here to Email MapMaker   Find more posts by MapMaker

Hi, I have a problem (what else?)
I have the ids,x-coords,and y-coords of about 200 different sprites stored in arrays:
( spritenum,x[spritenum],y[spritenum],0 )
and aslo about 50 other different sprites ids,x-coords,and y-coords stored in different arrays.
( spritenum2,x[spritenum2],y[spritenum2],1 )
Is there ANY possible way to tell the game to do something when two sprites have the same co-ordinates?
Ive been trying:

if x[spritenum]=[spritenum2] and y[spritenum]=[spritenum2]

.....

end if

but it dosnt work. Is there any way to do this?

Thanks,

MapMaker

03-03-2003 20:15

Posted by:
MapMaker

Location:
Edmonton, Alberta (Canada)

Click Here to Email MapMaker   Find more posts by MapMaker

ak sorry, amde a mistake in that script up there, it should be:

if x[spritenum]=x[spritenum2] and y[spritenum]=y[spritenum2]

(it still dosn't work)

03-03-2003 20:54

Posted by:
Machi

Click Here to Email Machi   Find more posts by Machi

The line that you have shown should work - really need to see more code to understand what's going wrong

03-04-2003 01:18

Posted by:
Machi

Click Here to Email Machi   Find more posts by Machi

... and I'm assuming that these are only "potential" sprites - ie, not currently being shown on screen, because if they are on screen you can of course check for sprite collision.

I'm also assuming that you have some arrays declared something like this - (it was hard to tell from your example)

int x[200]
int y[200]

... and that you are populating these arrays by actually putting something in an "x" and a "y" and that you are NOT doing something like

int x[200]
int y[200]
int complete[200,200,200,2]
int spritenum

spritenum = 1

complete[spritenum,x[spritenum],y[spritenum],0] = 25 (or something)

... and expecting it to have put an x and y value that are equal to 25
... because it won't :-)

03-04-2003 14:54

Posted by:
MapMaker

Location:
Edmonton, Alberta (Canada)

Click Here to Email MapMaker   Find more posts by MapMaker

Ya, I have declare the arrays before, and im not doing something like the last bit of code there ;), but as for collisions, is there any way to check all of them at once and not each one at a time? Thats where I'm stuck.

03-04-2003 15:12

Posted by:
John Treece-Birch

Click Here to Email John Treece-Birch   Find more posts by John Treece-Birch

Sprite Col

The function Sprite Col can take a range of the first and last sprites to collide with. It works something like this...

if Sprite Col(0,1 to 10)

...that line will test if sprite 0 collides with any sprite between 1 and 10 inclusive. I'm not sure I've got the parameters in the right order though so you'd best check in the help system.

Thanks,
John

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.