void ball::update( sf::RenderTarget *target,ball *Ball,int i,int k)
{
this->updateAccel();
this->dx = (this->balls.getRadius() + this->balls.getPosition().x) -
(Ball->getRadius() + Ball->getBounds().x);
this->dy = (this->balls.getRadius() + this->balls.getPosition().y) -
(Ball->getRadius() + Ball->getBounds().y);
this->distance = sqrt((this->dx * this->dx) + (this->dy * this->dy));
if(i != k) {
if (this->distance <= this->balls.getRadius() + Ball->getRadius()) {
this->velocity *= -1.f;
std::cout << "Collision!" << "\n";
return;
}
return;
}
this->updateCollision(target);
}
for(int i = 0; i < this->balls.size();i++) {
for (int k = 0; k < this->balls.size(); k++) {
this->balls[i].update(this->window, &this->balls[k],i,k);
}
}