diff options
| author | Aldrik Ramaekers <aldrik@amftech.nl> | 2023-10-28 15:39:00 +0200 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrik@amftech.nl> | 2023-10-28 15:39:00 +0200 |
| commit | 1ac22220f6077b3367456384b4bb563f1c5c2d29 (patch) | |
| tree | 4a85a2af22fb76e029698638581e738a95ff9957 /src/audio.c | |
| parent | 2f3be64ddfcd5beac009b56cee34812e20849ef1 (diff) | |
sound effects, throwable speed
Diffstat (limited to 'src/audio.c')
| -rw-r--r-- | src/audio.c | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/src/audio.c b/src/audio.c index 4a10241..0c53538 100644 --- a/src/audio.c +++ b/src/audio.c @@ -1,61 +1,70 @@ #include "../include/audio.h" -void add_audio_event_to_queue(audio_event_type event, u32 playerid, vec3f position) { +void add_object_audio_event_to_queue(audio_event_type event, object_type obj, u32 playerid, vec3f position) { for (int i = 0; i < max_audio_events; i++) { if (audio_events[i].active) continue; - audio_events[i] = (audio_event){.active = true, .playerid = playerid, .position = position, .type = event}; + audio_events[i] = (audio_event){.active = true, .obj = obj, .playerid = playerid, .position = position, .type = event}; return; } } +void add_audio_event_to_queue(audio_event_type event, u32 playerid, vec3f position) { + add_object_audio_event_to_queue(event, OBJECT_NONE, playerid, position); +} + static int get_channel_from_audio_event_type(audio_event_type event) { switch (event) { case EVENT_BOUNCE_THROWABLE: return CHANNEL_THROWABLES; - case EVENT_SHOOT: return CHANNEL_SHOOTING; + case EVENT_SHOOT: case EVENT_RELOAD: return CHANNEL_SHOOTING; + case EVENT_IMPACT: return CHANNEL_IMPACT; default: return 0; } } -static Mix_Chunk* get_sample_from_audio_event_type(audio_event_type event, u32 playerid) { +static Mix_Chunk* get_sample_from_audio_event(audio_event event, u32 playerid) { player* p = get_player_by_id(playerid); if (!p) return 0; - switch (event) + switch (event.type) { case EVENT_BOUNCE_THROWABLE: return wav_throwable_bounce; case EVENT_SHOOT: { switch (p->guntype) { case GUN_MP5: return wav_shoot_mp5; - default: - break; + default: return wav_error; } } case EVENT_RELOAD: { switch (p->guntype) { case GUN_MP5: return wav_reload_mp5; - default: - break; + default: return wav_error; } } - default: - break; + case EVENT_IMPACT: { + switch (event.obj) + { + case OBJECT_PLANTBOX1: return wav_impact_wood; + default: return wav_error; + } + } + + default: return wav_error; } } void play_sounds_in_queue() { for (int i = 0; i < max_audio_events; i++) { if (!audio_events[i].active) continue; - play_positioned_sound( get_channel_from_audio_event_type(audio_events[i].type), - get_sample_from_audio_event_type(audio_events[i].type, audio_events[i].playerid), + get_sample_from_audio_event(audio_events[i], audio_events[i].playerid), audio_events[i].position, 20); } } |
