summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAldrik Ramaekers <aldrik@amftech.nl>2023-12-24 11:55:06 +0100
committerAldrik Ramaekers <aldrik@amftech.nl>2023-12-24 11:55:06 +0100
commiteefc69b2c3816ed4c97bf976b7373175b8e7343d (patch)
treebf4b146e2667daacc7d5c838ee96c170966b306e /src
parentff3de32a164619ee1599c4f43600872f6cf955c4 (diff)
auudio
Diffstat (limited to 'src')
-rw-r--r--src/asset_defs.c6
-rw-r--r--src/audio.c8
-rw-r--r--src/bullets.c2
-rw-r--r--src/zombies.c2
4 files changed, 15 insertions, 3 deletions
diff --git a/src/asset_defs.c b/src/asset_defs.c
index f53c5ea..c4caf68 100644
--- a/src/asset_defs.c
+++ b/src/asset_defs.c
@@ -70,6 +70,12 @@ void load_assets() {
wav_character = Mix_LoadWAV("data/sounds/character.wav");
wav_step = Mix_LoadWAV("data/sounds/step.wav");
+ for (int i = 1; i <= NUM_SCREECHES; i++) {
+ char path[100];
+ sprintf(path, "data/sounds/screech%d.wav", i);
+ wav_screech[i] = Mix_LoadWAV(path);
+ }
+
// music
music_inside1 = Mix_LoadMUS("data/sounds/music_inside1.mp3");
}
diff --git a/src/audio.c b/src/audio.c
index 696b9ec..4dbcdc9 100644
--- a/src/audio.c
+++ b/src/audio.c
@@ -9,11 +9,11 @@ void add_throwable_audio_event_to_queue(audio_event_type event, throwable_type t
}
}
-void add_zombie_audio_event_to_queue(audio_event_type event, zombie_type zombie, u32 playerid, vec3f position) {
+void add_zombie_audio_event_to_queue(audio_event_type event, zombie_type zombie, vec3f position) {
for (int i = 0; i < max_audio_events; i++) {
if (audio_events[i].active) continue;
- audio_events[i] = (audio_event){.active = true, .throwable = THROWABLE_NONE, .obj = OBJECT_NONE, .zombie = zombie, .playerid = playerid, .position = position, .type = event};
+ audio_events[i] = (audio_event){.active = true, .throwable = THROWABLE_NONE, .obj = OBJECT_NONE, .zombie = zombie, .playerid = -1, .position = position, .type = event};
return;
}
}
@@ -97,6 +97,10 @@ static Mix_Chunk* get_sample_from_audio_event(audio_event event, u32 playerid) {
}
}
}
+ case EVENT_ZOMBIESCREECH: {
+ int random_screech_index = rand() % NUM_SCREECHES;
+ return wav_screech[random_screech_index];
+ }
default: return wav_error;
}
diff --git a/src/bullets.c b/src/bullets.c
index 6cb4b66..c8fc6e9 100644
--- a/src/bullets.c
+++ b/src/bullets.c
@@ -247,7 +247,7 @@ void update_bullets_server(platform_window* window) {
b = bullets[i];
add_points_to_player(p, POINTS_PER_HIT);
- add_zombie_audio_event_to_queue(EVENT_IMPACT, ZOMBIE_TYPE_NORMAL, p->id, (vec3f){.x = p->playerx, .y = p->playery, .z = p->height});
+ add_zombie_audio_event_to_queue(EVENT_IMPACT, ZOMBIE_TYPE_NORMAL, (vec3f){.x = p->playerx, .y = p->playery, .z = p->height});
}
}
}
diff --git a/src/zombies.c b/src/zombies.c
index 6bb4eb6..1006e95 100644
--- a/src/zombies.c
+++ b/src/zombies.c
@@ -54,6 +54,8 @@ bool hit_zombie(int index, int damage) {
int chunk_count = rand() % 4 + 1;
for (int c = 0; c < chunk_count; c++) spawn_zombie_chunk(center);
+ add_zombie_audio_event_to_queue(EVENT_ZOMBIESCREECH, zombies[index].type, zombies[index].position);
+
zombies[index].alive = false;
spawn_drop(zombies[index].position);
return true;