aboutsummaryrefslogtreecommitdiff
path: root/universe.c
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2023-04-13 11:09:13 +0000
committerrodri <rgl@antares-labs.eu>2023-04-13 11:09:13 +0000
commit00f7d8dd3dc47ed3cfa951325e809a92c37341b7 (patch)
treebfe2916f4c3d4f0b5f659563bb61586633e7578b /universe.c
parent42ea627853d79a54ef956a831e2f8badff5bfdb8 (diff)
downloadmusw-00f7d8dd3dc47ed3cfa951325e809a92c37341b7.tar.gz
musw-00f7d8dd3dc47ed3cfa951325e809a92c37341b7.tar.bz2
musw-00f7d8dd3dc47ed3cfa951325e809a92c37341b7.zip
now using PNG files instead of image(6)s. bullet TTL taken into account during stepping.
Diffstat (limited to 'universe.c')
-rw-r--r--universe.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/universe.c b/universe.c
index 0b3028f..3984488 100644
--- a/universe.c
+++ b/universe.c
@@ -55,6 +55,7 @@ ship_fire(Ship *s)
s->rounds[i].p = s->p;
s->rounds[i].v = addpt2(s->v, bv);
s->rounds[i].θ = s->θ;
+ s->rounds[i].ttl = 5;
s->rounds[i].fired++;
break;
}
@@ -65,7 +66,14 @@ ship_fire(Ship *s)
static void
universe_step(Universe *u, double Δt)
{
+ Ship *s;
+ Bullet *b;
+
integrate(u, u->t, Δt);
+ for(s = u->ships; s < u->ships+nelem(u->ships); s++)
+ for(b = s->rounds; b < s->rounds+nelem(s->rounds); b++)
+ if(b->fired)
+ b->ttl -= Δt;
u->timeacc -= Δt;
u->t += Δt;
}
@@ -96,7 +104,10 @@ universe_collide(Universe *u)
for(s = u->ships; s < u->ships+nelem(u->ships); s++){
for(b = s->rounds; b < s->rounds+nelem(s->rounds); b++){
- warp(b);
+ if(b->fired && b->ttl <= 0)
+ b->fired = 0;
+ if(b->fired)
+ warp(b);
}
warp(s);
}