Help checking multiple collisions in a Function

BlitzPlus Forums/BlitzPlus Beginners Area/Help checking multiple collisions in a Function

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Yes, I want to say use types but I understand where you're at and it is possible to do it with arrays. So here goes.

I'm assuming you want to check each part if its colliding with all the other parts. Lets say you have 5 parts, for simplicity's sake.

Ok first you want to set up a For...Next loop from 0 to 4 to check all 5 parts. Then, inside that loop, you want to see if it is colliding with any of the other parts by adding another loop.

Function partcollision()
For r= 0 to 4
  For t=0 to 4
     If ImagesCollide(part,partlist(1,r),partlist(2,r),0,part,partlist(1,t),partlist(2,t),0)
    counter=counter+1
  Next
Next
counter=counter-5
End Function


So here, we see its going to check each collision with each other collision by using 2 For...Next loops. The line 'counter=counter-5' is added because under this system, it will count an object as colliding with itself. Obviously you don't want to count this in your calculation, so you subtract it out.

Hopefully that helps.