nested types and deleting them.

Blitz3D Forums/Blitz3D Programming/nested types and deleting them.

Pongo(Posted 2006) [#1]
How would you go about this? I have a method now, but I don't like it at all.

I have a double loop here, and if a missle hits an enemy the enemy is removed, but I can't remove the missle, because it is looked for in the next loop around.

My current code moves the missle to an off screen area so it can be deleted later, but I don't like doing this.




WolRon(Posted 2006) [#2]
Easy method: Create an additional field in your m type so that you can mark it for deletion.

Then after your code above just
For m = Each weapon
	If m\destroy = True Then Delete m
Next



octothorpe(Posted 2006) [#3]
A \doomed field is probably the best solution for this sort of problem. I'm hesitant to recommend this, but you could fix the specific problem you have above by doing an Exit after you Delete m.


big10p(Posted 2006) [#4]
What's wrong with using Exit? This is exactly what the command is for.


WolRon(Posted 2006) [#5]
Because what if the weapon is within 1 unit from another entity at the same time?


big10p(Posted 2006) [#6]
Well, he says in his code that he wants to delete the weapon at the same time as the enemy i.e. each weapon only kills one enemy. Using Exit would allow this.