2 types colliding

Blitz3D Forums/Blitz3D Beginners Area/2 types colliding

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.

I am writing my first game (a pretty poor space invaders). When the players ship fires a bullet (of which there may be lots on the screen at the same time) how do I detect if ANY bullet has hit ANY alien without doing 2 loops which slow down the program too much (i.e. looping through every bullet and every alien) - I have looked through the forum and may be missing the answer. The collision function I've used is below.

Thanks for any help.

Function CheckCollision()
For bullet = Each bulletdata
For alien = Each aliendata
If Imagescollide(bullets,bullet\xpos,bullet\ypos,Aliens,Alien\xpos,Alien\ypos) Then
PlaySound Alienhit
score = score + 20
Delete Alien
EndIf
Next
Next
End Function