aboutsummaryrefslogtreecommitdiff
path: root/rect.c
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2023-05-05 13:44:23 +1000
committerquou <quou@disroot.org>2023-05-05 13:44:23 +1000
commitfb104368dd33b66e0575dcc0327cbae7046a4e1e (patch)
tree67a1a66182aa8417b8fbb431576528c28f4a5ab8 /rect.c
parent280552fa4750b5dac9243782f9c0a7e0b7eea6f8 (diff)
Add killing enemies.
Diffstat (limited to 'rect.c')
-rw-r--r--rect.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/rect.c b/rect.c
index ec755e2..aafa645 100644
--- a/rect.c
+++ b/rect.c
@@ -8,3 +8,28 @@ Rectangle make_rect(int x, int y, int w, int h) {
r.h = h;
return r;
}
+
+int rects_overlap(const Rectangle* a, const Rectangle* b) {
+ return
+ a->x + a->w > b->x &&
+ a->y + a->h > b->y &&
+ a->x < b->x + b->w &&
+ a->y < b->y + b->h;
+}
+
+int rects_overlap2(
+ int x0,
+ int y0,
+ int w0,
+ int h0,
+ int x1,
+ int y1,
+ int w1,
+ int h1
+) {
+ return
+ x0 + w0 > x1 &&
+ y0 + h0 > y1 &&
+ x0 < x1 + w1 &&
+ y0 < y1 + h1;
+}