I'm assisting another guy with making a 2d action game, but there is a small disagreement as to how we should be handling collision detections. One of us has his approach, the other has his, both of us think theirs is faster.
Assuming the collision detection runs for all objects on the map (because it does).
Which of these solutions is more effective? Is there a better way to do it?
bool check_collision(int x1, int y1, int x2, int y2, int r1, int r2) {
float d_x=x1-x2, d_y=y1-y2;
if (sqrt(d_x*d_x+d_y*d_y)<r1+r2) return true;
else return false; }
bool check_collision(int x1, int y1, int x2, int y2, int r1, int r2){
int d_x=abs(x1-x2), r_t=r1+r2;
if (d_x<r_t) { int d_y=abs(y1-y2);
if (d_y<r_t) { if (d_x*d_x+d_y*d_y<r_t*r_t) return true;
else return false; }
else return false; } }
else return false; }













