Rats! I thought I was done but now I have some additional comments...
You mentioned in this thread that some of the red squares are deleting each other when the collide, particularly when path-finding around the barriers. That is obvious given the the detection of;
for e=6 to 15
k = object collision(e, 0)
if k > 0 and k < 20
if k <> selection(0)
hide object e
endif
endif
next e
Because you also testing verses the object numbers of 6 through 15 by the "k > 0 and k < 20." While the original I posted does work providing that the horizontal positions of the red boxes does not change (relative to each other since they are placed to not be colliding when created,) if they move side-to-side the if statement will be more complex as in;
if k > 0 and k < 6 or k > 15 and k < 20
because you have to avoid testing the enemy against itself. This is why I told you the object numbers needed to be changed, such that say, objects 1 to 300 are for the player to move around, 400 to 600 are enemy, 1000 and up are bullets, and so on. In that case opject number 8000 say would be the selection box, to give yourself room to make the tests easier. If you did this, the selection code would be easier too, instead of;
rem the select bit (replace with distance equation) Player 1
if player(0)=1
if mouseclick()=1
rem -- here we move any object selected by the user
if selection(0)
position object selection(0),object position x(20),object position y(20),object position z(20)
else
t = object collision(20,0)
rem -- here we test for all user movable objects...
if t > 0 and t < 6
selection(0) = t
endif
if t > 15 and t < 20
selection(0) = t
endif
if t > 199 and t < 207
selection(0) = t
endif
endif
else
selection(0) = 0
endif
endif
return
it would become;
rem the select bit (replace with distance equation) Player 1
if player(0)=1
if mouseclick()=1
rem -- here we move any object selected by the user
if selection(0)
position object selection(0),object position x(8000),object position y(8000),object position z(8000)
else
t = object collision(8000,0)
rem -- here we test for all user movable objects...
if t > 0 and t < 300
selection(0) = t
endif
else
selection(0) = 0
endif
endif
return
Takes a bit of time to change the numbers I know, but I think you'd be happier with the result...
Take Care & Good Luck!
S.
Any truly great code should be indisguishable from magic.