summaryrefslogtreecommitdiff
path: root/src/bullets.c
diff options
context:
space:
mode:
authorAldrik Ramaekers <aldrik@amftech.nl>2023-10-29 09:40:38 +0100
committerAldrik Ramaekers <aldrik@amftech.nl>2023-10-29 09:40:38 +0100
commitdda7cfb99e9e8664878bcd38e3d3392b544c3343 (patch)
tree9e824e014510ca436a1697546e0fce3412970594 /src/bullets.c
parent2bcffc7def20dd1e660d742f54bd97307b9f193d (diff)
grenade explosion
Diffstat (limited to 'src/bullets.c')
-rw-r--r--src/bullets.c21
1 files changed, 3 insertions, 18 deletions
diff --git a/src/bullets.c b/src/bullets.c
index 403b1b6..9441ead 100644
--- a/src/bullets.c
+++ b/src/bullets.c
@@ -159,26 +159,11 @@ bool check_if_bullet_collided_with_zombie(bullet* b, platform_window* window, pl
if (result) {
b->endy = intersect_point_of_closest_zombie.y;
b->endx = intersect_point_of_closest_zombie.x;
- zombies[index_of_closest_zombie].health -= b->damage;
- b->damage = 0;
-
- // Random chunks when zombie is hit.
- if (rand() % 5 == 0) {
- spawn_zombie_chunk(get_center_of_square(zombies[index_of_closest_zombie].position, zombies[index_of_closest_zombie].size));
- }
-
- if (zombies[index_of_closest_zombie].health <= 0) {
- vec3f center = get_center_of_square(zombies[index_of_closest_zombie].position, zombies[index_of_closest_zombie].size);
- spawn_zombie_splatter(center);
-
- // Random chunks when zombie dies.
- int chunk_count = rand() % 4 + 1;
- for (int c = 0; c < chunk_count; c++) spawn_zombie_chunk(center);
-
- zombies[index_of_closest_zombie].alive = false;
- spawn_drop(zombies[index_of_closest_zombie].position);
+
+ if (hit_zombie(index_of_closest_zombie, b->damage)) {
p->kills++;
}
+ b->damage = 0;
}
return result;