Clone Contact Test (my remix of @colinmacc's remix) 1 Sprite, 2n (4-13) clones of which bounce around the Stage. When a Clone of A hits a Clone of B, @Duezz wanted a simple way for each Clone to detect which of the other Sprite's Clones it hit. My original project was a really simple solution to that problem ... but it had flaws. Well it was simple until @colinmac remixed it. His remix was still simple and very elegant, but it had a minor issue that @colinmacc conceded made it virtually useless, which was that it could not detect which Clone had hit which other Clone if more than one collision happened in the same frame. Most of my attempts (via this remix) to fix that problem, made it a lot more complicated and they were also miserable failures. However this one, which unlike the others, actually works, is a little less complicated. As @colinmacc pointed out to me, it has ended up becoming more or less a combination of his solution and @kriblo's solution. I spent way too much time and effort on it, but in the end I am quite proud of the end result, and the fact that I didn't give up, although I was tempted to many times. It now also reports all collisions (A-B, A-A & B-B), and calculates a much more realistic bounce angle, instead of the previous often very unrealistic "turn (pick random 170 to 190)". However it doesn't obey the laws of physics (there is no momentum transfer), which really should be calculated using the proper "physics of elastic collisions" formulas, which I can't quite get my head around. The inaccuracy of my calculations is the reason why 2 clones sometimes got "stuck together" for a period of time. However I have now made an adjustment to prevent that happening.
Thanks to @colinmacc for his very clever remix of my original project, that removed the need for my tiny wait on every collision and guaranteed perfect results, except when there is more than one collision in the same frame, in which case it seemed impossible to determine which clone hit which clone of the other variety. This remix is my 5th attempt (the other 4 were dismal failures) to fix that problem with @colinmacc's remix. However this one actually works. It basically concludes that whichever Clone, whose distance between me and it (or at least the square of it, no need to get the sqrt) is the smallest (closest to me), must be the one that hit me (or if more than one hit me, the one that hit me 1st). So no erroneous hits can be reported. It now also calculates a much more realistic bounce angle. The algorithm for determining that angle was derived from my 2017 project "Double Bubble Trouble" - https://scratch.mit.edu/projects/150784180/, but it has flaws that are documented in the Tutorial in the project. Essentially it assumes that the Tangent formed at the point where 2 Clones collide is actually an invisible physical wall that each Ball bounces off. It produces fairly realistic bounces but not the mathematically correct ones, which really should be calculated using the proper "physics of elastic collisions" formulas, which I can't quite get my head around. The inaccuracy of my calculation is the reason why 2 clones sometimes got "stuck together" for a period of time. However I have now made an adjustment to prevent that happening. The final change was based on the realisation that the code for both Ball Sprites was identical, so it seemed much more sensible to delete one of them, and just have 2 costumes for one Sprite.