aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2020-06-15 06:41:56 +0000
committerrodri <rgl@antares-labs.eu>2020-06-15 06:41:56 +0000
commitc068285f1ce7870e64c14341a3e9cfa79f6de6aa (patch)
tree8ded3bd38dbbc1ae36092169a0da284dc6af50dc
parent4913576c796b473892aa2d3e5d87f191fd0e915a (diff)
downloadboids-c068285f1ce7870e64c14341a3e9cfa79f6de6aa.tar.gz
boids-c068285f1ce7870e64c14341a3e9cfa79f6de6aa.tar.bz2
boids-c068285f1ce7870e64c14341a3e9cfa79f6de6aa.zip
cleanup and adjustments.
-rw-r--r--main.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/main.c b/main.c
index 1971e68..932ba91 100644
--- a/main.c
+++ b/main.c
@@ -58,8 +58,9 @@ newflock(int nbirds, Rectangle jail)
f = malloc(sizeof(Flock));
if(f == nil)
sysfatal("malloc: %r");
- setmalloctag(f, getcallerpc(&nbirds));
- f->birds = nil;
+ f->birds = malloc(nbirds*sizeof(Bird));
+ if(f->birds == nil)
+ sysfatal("malloc: %r");
f->nbirds = nbirds;
f->jail = jail;
f->separate = flockseparate;
@@ -67,10 +68,6 @@ newflock(int nbirds, Rectangle jail)
f->cohesion = flockcohesion;
f->step = flockstep;
- f->birds = malloc(nbirds*sizeof(Bird));
- if(f->birds == nil)
- sysfatal("malloc: %r");
- setmalloctag(f->birds, getcallerpc(&nbirds));
for(b = f->birds; b < f->birds + f->nbirds; b++){
b->p = Pt2(frand()*jail.max.x + jail.min.x,frand()*jail.max.y + jail.min.y,1);
b->v = Vec2(cos(frand()*2*PI),sin(frand()*2*PI));
@@ -158,7 +155,7 @@ void
flockstep(Flock *f)
{
static double Δt = 1;
- static Point2 a = {2,2}; /* deceleration */
+ static Point2 a = {1,1}; /* deceleration */
Bird *b;
f->separate(f);