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;
|
float omg;
|
||||||
unsigned shapes[MAX_SHAPES_PER_ENTITY];
|
unsigned shapes[MAX_SHAPES_PER_ENTITY];
|
||||||
unsigned shape_count;
|
unsigned shape_count;
|
||||||
float collision_radius;
|
float radius;
|
||||||
collision_tag_t tag;
|
collision_tag_t tag;
|
||||||
bool wrap;
|
bool wrap;
|
||||||
bool dead;
|
bool dead;
|
||||||
@@ -135,7 +135,7 @@ static void shoot()
|
|||||||
ship->pos, mat2_mul_vec2(ship->dir, ship_shape->verts[0]));
|
ship->pos, mat2_mul_vec2(ship->dir, ship_shape->verts[0]));
|
||||||
e->vel = vec2_add(
|
e->vel = vec2_add(
|
||||||
ship->vel, mat2_mul_vec2(ship->dir, (vec2_t) { 0, SHOT_VEL }));
|
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;
|
e->tag = COLLISION_SHOT;
|
||||||
|
|
||||||
shape_t *s = add_shape(id, nullptr);
|
shape_t *s = add_shape(id, nullptr);
|
||||||
@@ -149,7 +149,7 @@ static entity_t *gen_asteroid(float r_mean)
|
|||||||
unsigned id;
|
unsigned id;
|
||||||
entity_t *e = add_entity(&id);
|
entity_t *e = add_entity(&id);
|
||||||
e->wrap = true;
|
e->wrap = true;
|
||||||
e->collision_radius = r_mean;
|
e->radius = r_mean;
|
||||||
e->tag = COLLISION_ASTEROID;
|
e->tag = COLLISION_ASTEROID;
|
||||||
|
|
||||||
shape_t *s = add_shape(id, nullptr);
|
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) {
|
for (unsigned j = i + 1; j < entity_count; ++j) {
|
||||||
const entity_t *b = entities + j;
|
const entity_t *b = entities + j;
|
||||||
const float r = vec2_len(vec2_sub(b->pos, a->pos));
|
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);
|
assert(count < MAX_COLLISIONS);
|
||||||
collision_t *col = out + count++;
|
collision_t *col = out + count++;
|
||||||
col->entities[0] = i;
|
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)
|
if (a->tag == COLLISION_SHOT && b->tag == COLLISION_SHOT)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (a->tag == COLLISION_ASTEROID && b->tag == COLLISION_ASTEROID) { }
|
||||||
|
|
||||||
if (a->tag == COLLISION_SHOT) {
|
if (a->tag == COLLISION_SHOT) {
|
||||||
a->dead = true;
|
a->dead = true;
|
||||||
b->dead = true;
|
b->dead = true;
|
||||||
@@ -302,7 +304,7 @@ void game_init(float _aspect)
|
|||||||
|
|
||||||
entity_t *ship = add_entity(&ship_entity_id);
|
entity_t *ship = add_entity(&ship_entity_id);
|
||||||
ship->wrap = true;
|
ship->wrap = true;
|
||||||
ship->collision_radius = SHIP_COLLIDE_R;
|
ship->radius = SHIP_COLLIDE_R;
|
||||||
ship->tag = COLLISION_SHIP;
|
ship->tag = COLLISION_SHIP;
|
||||||
|
|
||||||
shape_t *ship_shape = add_shape(ship_entity_id, &ship_shape_id);
|
shape_t *ship_shape = add_shape(ship_entity_id, &ship_shape_id);
|
||||||
|
|||||||
Reference in New Issue
Block a user