From b05a4b3fe49847dd18f7d478d4da4250c6a9e8a8 Mon Sep 17 00:00:00 2001 From: Camden Dixie O'Brien Date: Tue, 14 Oct 2025 16:56:53 +0100 Subject: [PATCH] Rename collision_radius to just radius --- game.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/game.c b/game.c index a021173..5e6743c 100644 --- a/game.c +++ b/game.c @@ -53,7 +53,7 @@ typedef struct { float omg; unsigned shapes[MAX_SHAPES_PER_ENTITY]; unsigned shape_count; - float collision_radius; + float radius; collision_tag_t tag; bool wrap; bool dead; @@ -135,7 +135,7 @@ static void shoot() ship->pos, mat2_mul_vec2(ship->dir, ship_shape->verts[0])); e->vel = vec2_add( ship->vel, mat2_mul_vec2(ship->dir, (vec2_t) { 0, SHOT_VEL })); - e->collision_radius = SHIP_COLLIDE_R; + e->radius = SHIP_COLLIDE_R; e->tag = COLLISION_SHOT; shape_t *s = add_shape(id, nullptr); @@ -149,7 +149,7 @@ static entity_t *gen_asteroid(float r_mean) unsigned id; entity_t *e = add_entity(&id); e->wrap = true; - e->collision_radius = r_mean; + e->radius = r_mean; e->tag = COLLISION_ASTEROID; shape_t *s = add_shape(id, nullptr); @@ -250,7 +250,7 @@ static unsigned check_collisions(collision_t *out) for (unsigned j = i + 1; j < entity_count; ++j) { const entity_t *b = entities + j; const float r = vec2_len(vec2_sub(b->pos, a->pos)); - if (r <= a->collision_radius + b->collision_radius) { + if (r <= a->radius + b->radius) { assert(count < MAX_COLLISIONS); collision_t *col = out + count++; col->entities[0] = i; @@ -276,6 +276,8 @@ static void handle_collisions(const collision_t *collisions, unsigned count) if (a->tag == COLLISION_SHOT && b->tag == COLLISION_SHOT) continue; + if (a->tag == COLLISION_ASTEROID && b->tag == COLLISION_ASTEROID) { } + if (a->tag == COLLISION_SHOT) { a->dead = true; b->dead = true; @@ -302,7 +304,7 @@ void game_init(float _aspect) entity_t *ship = add_entity(&ship_entity_id); ship->wrap = true; - ship->collision_radius = SHIP_COLLIDE_R; + ship->radius = SHIP_COLLIDE_R; ship->tag = COLLISION_SHIP; shape_t *ship_shape = add_shape(ship_entity_id, &ship_shape_id);