From be5c7263406aef867501c7965bcced6a7e2898a6 Mon Sep 17 00:00:00 2001 From: quou Date: Sun, 29 Sep 2024 16:39:31 +1000 Subject: animation, player movement, physics etc. --- rect.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'rect.c') diff --git a/rect.c b/rect.c index 69758c1..a35052d 100644 --- a/rect.c +++ b/rect.c @@ -1,5 +1,21 @@ #include "rect.h" +int rects_overlap(const Rect* a, const Rect* 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 point_rect_overlap(const Rect* r, int px, int py) { + return + px >= r->x && + py >= r->y && + px <= r->x + r->w && + py <= r->y + r->h; +} + Rect* rect_clip(Rect* r, const Rect* c) { int n; if ((n = c->x - r->x) > 0) { -- cgit v1.2.3-54-g00ecf