Right now I have a list of 5 circles. I want them to pull towards the center, but also push away from each other. I can get them to pull towards the center or push away from each other, but not both. Would love some help with this.
Some source code:
for (var i = 0; i < socials.length; i++) {
for (var j = 0; j < socials.length; j++) {
if (j != i) {
if (getDistance(socials[i].x, socials[i].y, socials[j].x, socials[j].y) < socials[i].radius + socials[j].radius + socialsPadding) {
socials[i].accX += (socials[i].x - socials[j].x) / 100;
socials[i].accY += (socials[i].y - socials[j].y) / 100;
}
}
}
socials[i].xVel = (socialRect.width/2 - socials[i].x + socials[i].accX) / 10;
socials[i].yVel = (socialRect.height/2 - socials[i].y + socials[i].accY) / 10;
socials[i].x += socials[i].xVel;
socials[i].y += socials[i].yVel;
socials[i].radius += (socials[i].destRadius - socials[i].radius) / 10;
socialBubbles[i].style.width = (socials[i].radius * 2) + "px";
socialBubbles[i].style.height = (socials[i].radius * 2) + "px";
socialBubbles[i].style.transform = "translateX(" + (socials[i].x - socials[i].radius) + "px) translateY(" + (socials[i].y - socials[i].radius) + "px)";
}