forked from jaildesigner-jailgames/jaildoctors_dilemma
linter
This commit is contained in:
@@ -42,29 +42,29 @@ bool checkCollision(const Circle& a, const Circle& b) {
|
||||
bool checkCollision(const Circle& a, const SDL_FRect& rect) {
|
||||
SDL_Rect b = toSDLRect(rect);
|
||||
// Closest point on collision box
|
||||
int cX;
|
||||
int cY;
|
||||
int c_x;
|
||||
int c_y;
|
||||
|
||||
// Find closest x offset
|
||||
if (a.x < b.x) {
|
||||
cX = b.x;
|
||||
c_x = b.x;
|
||||
} else if (a.x > b.x + b.w) {
|
||||
cX = b.x + b.w;
|
||||
c_x = b.x + b.w;
|
||||
} else {
|
||||
cX = a.x;
|
||||
c_x = a.x;
|
||||
}
|
||||
|
||||
// Find closest y offset
|
||||
if (a.y < b.y) {
|
||||
cY = b.y;
|
||||
c_y = b.y;
|
||||
} else if (a.y > b.y + b.h) {
|
||||
cY = b.y + b.h;
|
||||
c_y = b.y + b.h;
|
||||
} else {
|
||||
cY = a.y;
|
||||
c_y = a.y;
|
||||
}
|
||||
|
||||
// If the closest point is inside the circle_t
|
||||
if (distanceSquared(a.x, a.y, cX, cY) < a.r * a.r) {
|
||||
if (distanceSquared(a.x, a.y, c_x, c_y) < a.r * a.r) {
|
||||
// This box and the circle_t have collided
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user