Something like this maybe?
c = getFirstContact()
while c > 0
match = 0
s1 = getContactSpriteID1()
s2 = getContactSpriteID2()
if s1 = player.sprite or s2 = player.sprite then match = match + 1
if s1 = bullet or s2 = bullet then match = match + 2
if getSpriteType(s1) = 1 then match = match + 4
if getSpriteType(s2) = 1 then match = match + 8
if match = 5 then playerAsteroidCollide()
if match = 6 then bulletAsteroidCollide()
if match = 12 then playSound(_snd_Hit1)
c = getNextContact()
endwhile
function getSpriteType(s)
for i = 0 to _index_Asteroids-1
if asteroids[i].sprite = s then exitfunction 1
next i
endfunction 0
If you just want to do the same routine for any sprite that hits the player then you won't need the array like I do. But since I have multiple types of sprites that can collide, I need to know which is which.
An alternative approach I just thought of eliminates my immediate need for the array and extra function. Since I only have 1 player sprite and only 1 bullet and the rest are asteroids, I can do the following:
c = getFirstContact()
while c > 0
match = 0
s1 = getContactSpriteID1()
s2 = getContactSpriteID2()
if s1 = player.sprite or s2 = player.sprite then match = match + 1
if s1 = bullet or s2 = bullet then match = match + 2
// if collision does NOT involve a bullet
if (match >> 1) && %00000001 <> 1 then playerAsteroidCollide()
if match = 6 then bulletAsteroidCollide()
if match = 12 then playSound(_snd_Hit1)
c = getNextContact()
endwhile
If I did have multiple bullets, then if they used the same image I could then do:
Global imgBullet = loadImage("bullet.png")
array[i] = createSprite(imgBullet)
if getSpriteImageID(s1) = imgBullet