blob: 5bf7e395e3c5566278929b6c30d1ff7c071d9aca (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#include <stddef.h>
#include "balls.h"
int
isCollision(Vector p1, float r1, Vector p2, float r2) {
float dx, dy, rhs;
dx = p1.x - p2.x;
dy = p1.y - p2.y;
rhs = r1 + r2;
return (dx*dx + dy*dy) <= rhs*rhs;
}
Rectangle
insetRect(Rectangle r, float n) {
r.min.x += n;
r.min.y += n;
r.max.y -= n;
r.max.y -= n;
return r;
}
|