summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2024-10-31 20:06:47 -0400
committerSam Anthony <sam@samanthony.xyz>2024-10-31 20:06:47 -0400
commit11ca9986316d47f179bac21b5082880a3f517ba6 (patch)
treea8f80b631b5de57d3edd56b352e7c63f49edc337
parentd13db0592573332fe32d9668d822a0cc0c2e920e (diff)
downloadballs-11ca9986316d47f179bac21b5082880a3f517ba6.zip
change vector type from int to float
-rw-r--r--balls.h2
-rw-r--r--geo.c5
2 files changed, 3 insertions, 4 deletions
diff --git a/balls.h b/balls.h
index ef2589b..d796e5c 100644
--- a/balls.h
+++ b/balls.h
@@ -1,5 +1,5 @@
typedef struct {
- int x, y;
+ float x, y;
} Vector;
typedef struct {
diff --git a/geo.c b/geo.c
index 0f70eaf..976b668 100644
--- a/geo.c
+++ b/geo.c
@@ -28,15 +28,14 @@ insetRect(Rectangle r, float n) {
Vector *
noOverlapPositions(int n, Rectangle bounds, float radius) {
Vector *ps;
- Rectangle r;
int i, j;
if ((ps = malloc(n*sizeof(Vector))) == NULL)
sysfatal("Failed to allocate position array.\n");
- r = insetRect(bounds, radius);
+ bounds = insetRect(bounds, radius);
for (i = 0; i < n; i++) {
- ps[i] = randPtInRect(r);
+ ps[i] = randPtInRect(bounds);
for (j = 0; j < i; j++)
if (isCollision(ps[j], radius, ps[i], radius))
break;