Solution is to swap your nested For/Each's around in your collision code:
Alternatively, just exit the For/Each loop after deleting the enemy:
This is why it only caused an error if there was more than one bullet active at the time of collision.
Function kills() ;NEEDS WORK... BAD REAL BAD For b.bullet=Each bullet For e.enemy=Each enemy If RectsOverlap(e\x,e\y,10,10,b\x,b\y,10,10) Delete e End If Next Next End Function
Alternatively, just exit the For/Each loop after deleting the enemy:
Function kills() ;NEEDS WORK... BAD REAL BAD For e.enemy=Each enemy For b.bullet=Each bullet If RectsOverlap(e\x,e\y,10,10,b\x,b\y,10,10) Delete e Exit End If Next Next End FunctionBasically what you were doing wrong - when the first bullet collides with the enemy, you delete the enemy type itself. Your original code then proceeded to check the rest of the bullets for collisions against the now non-existent enemy.
This is why it only caused an error if there was more than one bullet active at the time of collision.