Add hit markers and metal explosion for turrets
Turrets now emit orange-white spark particles when taking non-lethal damage, giving clear visual feedback on hits. On death, turrets get a dedicated metal explosion effect (shrapnel, hot sparks, flash, smoke) instead of the generic death puff, with stronger screen shake. Closes #14
This commit was merged in pull request #25.
This commit is contained in:
@@ -177,36 +177,45 @@ static Camera *s_active_camera = NULL;
|
||||
|
||||
static void damage_entity(Entity *target, int damage) {
|
||||
target->health -= damage;
|
||||
|
||||
Vec2 center = vec2(
|
||||
target->body.pos.x + target->body.size.x * 0.5f,
|
||||
target->body.pos.y + target->body.size.y * 0.5f
|
||||
);
|
||||
|
||||
if (target->health <= 0) {
|
||||
target->flags |= ENTITY_DEAD;
|
||||
|
||||
/* Death particles — centered on entity */
|
||||
Vec2 center = vec2(
|
||||
target->body.pos.x + target->body.size.x * 0.5f,
|
||||
target->body.pos.y + target->body.size.y * 0.5f
|
||||
);
|
||||
SDL_Color death_color;
|
||||
if (target->type == ENT_ENEMY_GRUNT) {
|
||||
death_color = (SDL_Color){200, 60, 60, 255}; /* red debris */
|
||||
} else if (target->type == ENT_ENEMY_FLYER) {
|
||||
death_color = (SDL_Color){140, 80, 200, 255}; /* purple puff */
|
||||
} else if (target->type == ENT_TURRET || target->type == ENT_LASER_TURRET) {
|
||||
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 */
|
||||
/* Death particles — turrets get a metal explosion, others a puff */
|
||||
if (target->type == ENT_TURRET || target->type == ENT_LASER_TURRET) {
|
||||
particle_emit_metal_explosion(center);
|
||||
} else {
|
||||
death_color = (SDL_Color){200, 200, 200, 255}; /* grey */
|
||||
SDL_Color death_color;
|
||||
if (target->type == ENT_ENEMY_GRUNT) {
|
||||
death_color = (SDL_Color){200, 60, 60, 255};
|
||||
} else if (target->type == ENT_ENEMY_FLYER) {
|
||||
death_color = (SDL_Color){140, 80, 200, 255};
|
||||
} else if (target->type == ENT_ENEMY_CHARGER) {
|
||||
death_color = (SDL_Color){220, 140, 40, 255};
|
||||
} else if (target->type == ENT_SPAWNER) {
|
||||
death_color = (SDL_Color){180, 60, 180, 255};
|
||||
} else {
|
||||
death_color = (SDL_Color){200, 200, 200, 255};
|
||||
}
|
||||
particle_emit_death_puff(center, death_color);
|
||||
}
|
||||
particle_emit_death_puff(center, death_color);
|
||||
|
||||
/* Screen shake on kill */
|
||||
/* Screen shake on kill — stronger for turret explosions */
|
||||
if (s_active_camera) {
|
||||
camera_shake(s_active_camera, 2.0f, 0.15f);
|
||||
float intensity = (target->type == ENT_TURRET ||
|
||||
target->type == ENT_LASER_TURRET) ? 3.5f : 2.0f;
|
||||
camera_shake(s_active_camera, intensity, 0.15f);
|
||||
}
|
||||
|
||||
audio_play_sound_at(s_sfx_enemy_death, 80, center, 0);
|
||||
} else if (target->type == ENT_TURRET || target->type == ENT_LASER_TURRET) {
|
||||
/* Hit marker sparks on non-lethal turret damage */
|
||||
particle_emit_hit_sparks(center);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user