Fix missing collision for charger, spawner, and laser turret
All three new entity types were absent from the hardcoded enemy-type checks in is_enemy() (contact damage + projectile hits), homing projectile targeting, and drone targeting. Also adds proper death particle colors for charger (orange) and spawner (purple).
This commit is contained in:
@@ -35,7 +35,8 @@ static Entity *find_nearest_enemy(Vec2 from, float range) {
|
|||||||
Entity *e = &s_em->entities[i];
|
Entity *e = &s_em->entities[i];
|
||||||
if (!e->active || e->health <= 0) continue;
|
if (!e->active || e->health <= 0) continue;
|
||||||
if (e->type != ENT_ENEMY_GRUNT && e->type != ENT_ENEMY_FLYER &&
|
if (e->type != ENT_ENEMY_GRUNT && e->type != ENT_ENEMY_FLYER &&
|
||||||
e->type != ENT_TURRET) continue;
|
e->type != ENT_TURRET && e->type != ENT_ENEMY_CHARGER &&
|
||||||
|
e->type != ENT_SPAWNER && e->type != ENT_LASER_TURRET) continue;
|
||||||
Vec2 epos = vec2(e->body.pos.x + e->body.size.x * 0.5f,
|
Vec2 epos = vec2(e->body.pos.x + e->body.size.x * 0.5f,
|
||||||
e->body.pos.y + e->body.size.y * 0.5f);
|
e->body.pos.y + e->body.size.y * 0.5f);
|
||||||
float dx = epos.x - from.x;
|
float dx = epos.x - from.x;
|
||||||
|
|||||||
@@ -188,8 +188,12 @@ static void damage_entity(Entity *target, int damage) {
|
|||||||
death_color = (SDL_Color){200, 60, 60, 255}; /* red debris */
|
death_color = (SDL_Color){200, 60, 60, 255}; /* red debris */
|
||||||
} else if (target->type == ENT_ENEMY_FLYER) {
|
} else if (target->type == ENT_ENEMY_FLYER) {
|
||||||
death_color = (SDL_Color){140, 80, 200, 255}; /* purple puff */
|
death_color = (SDL_Color){140, 80, 200, 255}; /* purple puff */
|
||||||
} else if (target->type == ENT_TURRET) {
|
} else if (target->type == ENT_TURRET || target->type == ENT_LASER_TURRET) {
|
||||||
death_color = (SDL_Color){160, 160, 160, 255}; /* metal scraps */
|
death_color = (SDL_Color){160, 160, 160, 255}; /* metal scraps */
|
||||||
|
} else if (target->type == ENT_ENEMY_CHARGER) {
|
||||||
|
death_color = (SDL_Color){220, 140, 40, 255}; /* orange spark */
|
||||||
|
} else if (target->type == ENT_SPAWNER) {
|
||||||
|
death_color = (SDL_Color){180, 60, 180, 255}; /* purple burst */
|
||||||
} else {
|
} else {
|
||||||
death_color = (SDL_Color){200, 200, 200, 255}; /* grey */
|
death_color = (SDL_Color){200, 200, 200, 255}; /* grey */
|
||||||
}
|
}
|
||||||
@@ -231,7 +235,8 @@ static void damage_player(Entity *player, int damage, Entity *source) {
|
|||||||
|
|
||||||
static bool is_enemy(const Entity *e) {
|
static bool is_enemy(const Entity *e) {
|
||||||
return e->type == ENT_ENEMY_GRUNT || e->type == ENT_ENEMY_FLYER ||
|
return e->type == ENT_ENEMY_GRUNT || e->type == ENT_ENEMY_FLYER ||
|
||||||
e->type == ENT_TURRET;
|
e->type == ENT_TURRET || e->type == ENT_ENEMY_CHARGER ||
|
||||||
|
e->type == ENT_SPAWNER || e->type == ENT_LASER_TURRET;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_collisions(EntityManager *em) {
|
static void handle_collisions(EntityManager *em) {
|
||||||
|
|||||||
@@ -251,7 +251,9 @@ static void projectile_update(Entity *self, float dt, const Tilemap *map) {
|
|||||||
|
|
||||||
/* Player bullets target enemies, enemy bullets target player */
|
/* Player bullets target enemies, enemy bullets target player */
|
||||||
if (is_player_proj) {
|
if (is_player_proj) {
|
||||||
if (e->type != ENT_ENEMY_GRUNT && e->type != ENT_ENEMY_FLYER) continue;
|
if (e->type != ENT_ENEMY_GRUNT && e->type != ENT_ENEMY_FLYER &&
|
||||||
|
e->type != ENT_TURRET && e->type != ENT_ENEMY_CHARGER &&
|
||||||
|
e->type != ENT_SPAWNER && e->type != ENT_LASER_TURRET) continue;
|
||||||
} else {
|
} else {
|
||||||
if (e->type != ENT_PLAYER) continue;
|
if (e->type != ENT_PLAYER) continue;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user