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
5 Answers
+ 2
What do you mean by "meet at the same time"? What do X and Y you refer to?
+ 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
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?
0
That position X and Y of circle 1 reach position X and Y of circle 2 at the same time
0
Do you mean you want 2 circles meet at a fixed X and Y point, disregard of where they are?