Rename collision_radius to just radius
This commit is contained in:
12
game.c
12
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);
|
||||
|
||||
Reference in New Issue
Block a user