Problems
Math.atan2(y, x);
Math.atan2(±0, -0);// ±PI.
Math.atan2(±0, +0);// ±0.
Problems
Math.sin(x);
Math.cos(x);
Collision of spiders
Collision of spiders
for (let i = 0; i < spiders.length; i++) {
let mod = 1;
for (let j = i + 1; j < spiders.length; j++) {
mod++;
let count = 0;
while (travers(spiders[i], spiders[j]) && count++ < 4) {
if (mod % 2 == 0) {
if (spiders[i].pos.y > spiders[j].pos.y) {
++spiders[i].pos.y;
--spiders[j].pos.y;
} else {
--spiders[i].pos.y;
++spiders[j].pos.y;
}
} else {
if (spiders[i].pos.x > spiders[j].pos.x) {
++spiders[i].pos.x;
--spiders[j].pos.x;
} else {
--spiders[i].pos.x;
++spiders[j].pos.x;
}
}
}
}
}