0

How would you do it? JavaScript

I need the two circles to meet at the same time regardless of the distance of X and Y. I explain? https://code.sololearn.com/WvQtdVe7JYDx/?ref=app

12th Jul 2020, 8:37 AM
Propy Grammar Moruzian
Propy Grammar Moruzian - avatar
5 odpowiedzi
+ 2
What do you mean by "meet at the same time"? What do X and Y you refer to?
12th Jul 2020, 8:42 AM
Calviղ
Calviղ - avatar
+ 1
Use border-radius: 50%; for circle instead of if (c1PosX === c2PosX - width || c1PosY === c2PosY + width) { clearInterval(timer); } else { c1PosY+=1; c1PosX+=1; } } should be if (c1PosX === c2PosX && c1PosY === c2PosY) { clearInterval(timer); } else { if(c1PosY < c2PosY) c1PosY+=1; if(c1PosX < c2PosX) c1PosX+=1; } } https://code.sololearn.com/Wj4dLT7WJ8ej/?ref=app
12th Jul 2020, 9:58 AM
Gordon
Gordon - avatar
0
the position X and Y of circle one, is identical is to say that they collide, but for this I need a reference about the speed at which The circle should move one so that they collide at the same point. Already?
12th Jul 2020, 8:45 AM
Propy Grammar Moruzian
Propy Grammar Moruzian - avatar
0
That position X and Y of circle 1 reach position X and Y of circle 2 at the same time
12th Jul 2020, 8:48 AM
Propy Grammar Moruzian
Propy Grammar Moruzian - avatar
0
Do you mean you want 2 circles meet at a fixed X and Y point, disregard of where they are?
12th Jul 2020, 9:00 AM
Calviղ
Calviղ - avatar