diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2024-10-31 19:53:25 -0400 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2024-10-31 19:53:25 -0400 |
| commit | 111013b9ecb8b4208bfb1109e0f8ce8291fc90df (patch) | |
| tree | db67132d08569ade41c50b9e8948df3b094095d0 /geo.c | |
| parent | 8a3994c5f6fd7023b5bdff9a02bc1f0ba110f12f (diff) | |
| download | balls-111013b9ecb8b4208bfb1109e0f8ce8291fc90df.zip | |
remove gcc vector with struct
Diffstat (limited to 'geo.c')
| -rw-r--r-- | geo.c | 18 |
1 files changed, 11 insertions, 7 deletions
@@ -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; } |