I’m trying to make a collision code with circles. The primary objective is to change the color of the circles when they collide, but somehow it doesn’t work.
I can see the collision detection functions, but the colors change only when the circles are next to each other in the array.
Can someone please have a look to see what I’m doing wrong?
In the loop you are comparing each ball with all other balls. So you actually land in the
part all the time, and even if the balls changed color at some point they will change right back because likely no ball will ever collide with all other balls.
Before the double loop you want a:
for(let ball of balls) ball.noChangeColor();
to make them all green, and then just remove that `else` part.
I hope that gets you a step closer.
Thanks Haris ( exams ) that looks great. I see you basically used a similar solution as Schindlabua , by first setting the color, draw and then reset.
I moved my initial setting a bit based on your example now.
Thank you both for yet another lesson today 😃🌹🌹