Comparing type objects

BlitzMax Forums/BlitzMax Programming/Comparing type objects

Raz(Posted 2006) [#1]
Heyooo,

whats the easiest way of comparing each object in a type to every other object in the same type?

E.G. whether two enemies collide.

ta!


Grey Alien(Posted 2006) [#2]
Assuming you are not using CollideImage (perhaps you should, I do) unoptimised way is to loop though a list of types, and for each type in the list, loop through the list again testing against all the other types. Don't forget to not test the current type on itself or it will collide. This is easy though e.g.

If currenttype <> testtype then ...

A more optimised way will reduce the tests by half so you don't test A on B and then later B on A, which is pointless.


Raz(Posted 2006) [#3]
ta grey,

yeah I am using coord overlap for collisions. I did think about the type list within type list thing but assumed there might be a more efficient way of doing it. (not that I think this is inefficient or anything)

-Chris