summaryrefslogtreecommitdiffstats
path: root/geo.c
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2024-10-31 19:53:25 -0400
committerSam Anthony <sam@samanthony.xyz>2024-10-31 19:53:25 -0400
commit111013b9ecb8b4208bfb1109e0f8ce8291fc90df (patch)
treedb67132d08569ade41c50b9e8948df3b094095d0 /geo.c
parent8a3994c5f6fd7023b5bdff9a02bc1f0ba110f12f (diff)
downloadballs-111013b9ecb8b4208bfb1109e0f8ce8291fc90df.zip
remove gcc vector with struct
Diffstat (limited to 'geo.c')
-rw-r--r--geo.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/geo.c b/geo.c
index 6178bf6..5bf7e39 100644
--- a/geo.c
+++ b/geo.c
@@ -3,18 +3,22 @@
#include "balls.h"
int
-isCollision(float2 p1, float r1, float2 p2, float r2) {
- float2 dist;
- float rhs;
+isCollision(Vector p1, float r1, Vector p2, float r2) {
+ float dx, dy, rhs;
- dist = p1 - p2;
+ dx = p1.x - p2.x;
+ dy = p1.y - p2.y;
rhs = r1 + r2;
- return (dist[0]*dist[0] + dist[1]*dist[1]) <= rhs*rhs;
+ return (dx*dx + dy*dy) <= rhs*rhs;
}
Rectangle
insetRect(Rectangle r, float n) {
- r.min += n;
- r.max -= n;
+ r.min.x += n;
+ r.min.y += n;
+
+ r.max.y -= n;
+ r.max.y -= n;
+
return r;
}