diff options
author | quou <quou@disroot.org> | 2024-09-29 16:39:31 +1000 |
---|---|---|
committer | quou <quou@disroot.org> | 2024-09-29 16:39:31 +1000 |
commit | be5c7263406aef867501c7965bcced6a7e2898a6 (patch) | |
tree | 1e7d5d3b435456c9eeb2d094c3288df259246750 /rect.c | |
parent | 9ca0a79e9cc784e14c3d8111ccb9ea1a22225472 (diff) |
animation, player movement, physics etc.
Diffstat (limited to 'rect.c')
-rw-r--r-- | rect.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -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) { |