diff options
| author | Aldrik Ramaekers <aldrik@amftech.nl> | 2024-01-06 16:19:03 +0100 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrik@amftech.nl> | 2024-01-06 16:19:03 +0100 |
| commit | 08e0f1bef6555896e4d88e53c3f16f609c4e746c (patch) | |
| tree | 8fe124c7d278f26c9d2f0a01b320da20e2ac03c1 /src/audio.c | |
| parent | 0586263f1001297835c12f8f0edd3c3f803c3109 (diff) | |
zombie spawn roar, fix audio volume based on distance
Diffstat (limited to 'src/audio.c')
| -rw-r--r-- | src/audio.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/audio.c b/src/audio.c index ab81906..c97319b 100644 --- a/src/audio.c +++ b/src/audio.c @@ -81,6 +81,13 @@ static Mix_Chunk* get_sample_from_audio_event(audio_event event, u32 playerid) { } } + case EVENT_ZOMBIEROAR: { + switch (event.zombie) + { + case ZOMBIE_TYPE_ENRAGED: return wav_roar_enraged; + default: return wav_error; + } + } case EVENT_IMPACT: { if (event.zombie != ZOMBIE_TYPE_NONE) { switch (event.zombie) @@ -149,6 +156,7 @@ void play_positioned_sound(int channel, Mix_Chunk* wav, vec3f pos, float max_aud int tiles_between_throwable_and_player = distance_between_3f((vec3f){.x = p->playerx, .y = p->playery, .z = p->height}, pos); float volume = (tiles_between_throwable_and_player / max_audible_dist); if (volume > 1.0f) volume = 1.0f; + if (volume < 0.0f) volume = 0.0f; // calculate angle /* @@ -160,6 +168,6 @@ void play_positioned_sound(int channel, Mix_Chunk* wav, vec3f pos, float max_aud if (rads > 360) rads -= 360; */ - //Mix_SetPosition(0, 0, volume*255); + Mix_SetPosition(channel, 0, (int)(volume*255)); Mix_PlayChannel(channel, wav, 0); } |
