diff options
| author | Aldrik Ramaekers <aldrik@amftech.nl> | 2022-12-19 20:36:03 +0100 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrik@amftech.nl> | 2022-12-19 20:36:03 +0100 |
| commit | 1683c214b37c2bb8f3e43fd9054f3a53f7695f4a (patch) | |
| tree | 75413c601901ff95f15beced52af60f4d1f22d14 /src/bullets.c | |
| parent | 79efc8a8e9976bbdd41d4a47b58c71d3be9d4ff7 (diff) | |
splatter
Diffstat (limited to 'src/bullets.c')
| -rw-r--r-- | src/bullets.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/bullets.c b/src/bullets.c index 1449f93..d701b50 100644 --- a/src/bullets.c +++ b/src/bullets.c @@ -156,9 +156,19 @@ bool check_if_bullet_collided_with_zombie(bullet* b, platform_window* window, pl zombies[index_of_closest_zombie].health -= b->damage; b->damage = 0; - int chunk_count = rand() % 4 + 1; - for (int c = 0; c < chunk_count; c++) spawn_zombie_chunk(get_center_of_square(zombies[index_of_closest_zombie].position, zombies[index_of_closest_zombie].size)); + // 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); p->kills++; |
