This is what I like to do for collision. Depending on how expansive your game world is, it might not be feasible, but I usually do smaller games where this works fine.
Load and create objects that you want to test for collision like this:
`1: load/create the object and store information into an array
dim BadGuyA(MAXBadGuyA)
dim BadGuyB(MAXBadGuyB)
EnemyObject=UnusedObjectNumber
for P = 1 to MAXBadGuyA
load object "guy.x",EnemyObject
BadGuyA(P)=EnemyObject
inc EnemyObject
next P
for P = 1 to MAXBadGuyB
load object "guyb.x",EnemyObject
BadGuyB(P)=EnemyObject
inc EnemyObject
next P
`2: check for collision with that enemy type
if object collision(bullet,0)>=BadGuyA(1) and object collision(bullet,0)<=BadGuyA(MAXBadGuyA)
`all the stuff on the collision
endif
if object collision(bullet,0)>=BadGuyB(1) and object collision(bullet,0)<=BadGuyB(MAXBadGuyB)
`all the stuff on the collision
endif
`you can make a function out of this and use it to check many bullets at once
for P = MinBullet to MaxBullet `check active bullets
CheckBulletHit(P,BadGuyA(1),BadGuyA(MAXBadGuyA),1,3)
CheckBulletHit(P,BadGuyB(1),BadGuyB(MAXBadGuyB),2,4)
next P
function CheckBulletHit(BulletNumber,BadGuyMin,BadGuyMax,Flag1,Flag2)
if object collision(BulletNumber,0)>=BadGuyMin and object collision(BulletNumber,0)<=BadGuyMax
`all the stuff on the collision, Flag1 and Flag2 used create different effects in here.
endif
endfunction
I'm not sure of the speed of it but it's easy to code. You can easily pick out enemies (object position x(BadGuyA(3)), and when the second parameter of object collision is 0 it returns the object number the first parameter collides with. Very useful.