Track asteroid count

This commit is contained in:
2025-10-18 17:43:22 +01:00
parent bd6161505c
commit 7ed120899c

6
game.c
View File

@@ -104,6 +104,7 @@ static shape_t shapes[MAX_SHAPES];
static unsigned entity_count;
static unsigned shape_count;
static unsigned asteroid_count;
static bool dead;
static float aspect;
@@ -230,6 +231,8 @@ static void spawn_asteroid()
ASTEROID_VEL_JITTER * rng_plusminus(),
};
e->omg = ASTEROID_OMG_JITTER * rng_plusminus();
++asteroid_count;
}
static void remove_shape(unsigned id)
@@ -329,6 +332,7 @@ static void bounce(collision_t c)
static void destroy_asteroid(entity_t *a, vec2_t shot_vel)
{
a->dead = true;
--asteroid_count;
float r;
if (fabs(a->radius - ASTEROID_LARGE) < 1e-3)
@@ -363,6 +367,8 @@ static void destroy_asteroid(entity_t *a, vec2_t shot_vel)
e->pos = vec2_add(a->pos, disp);
e->vel = vec2_add(inherit_v, vec2_add(radial_v, jitter_v));
e->omg = a->omg / n + REPLACE_OMG_JITTER * rng_plusminus();
++asteroid_count;
}
}