audio: refactor audio asset loading, add crit sound
This commit is contained in:
parent
23dead8c0d
commit
a315b14dd1
5 changed files with 66 additions and 44 deletions
48
src/audio.c
48
src/audio.c
|
|
@ -1,5 +1,6 @@
|
|||
#include "audio.h"
|
||||
#include "raylib.h"
|
||||
#include "common.h"
|
||||
#include <math.h>
|
||||
#include <stddef.h>
|
||||
|
||||
|
|
@ -70,85 +71,80 @@ void audio_play_move(void) {
|
|||
play_tone(200.0f, 0.05f, 0.3f);
|
||||
}
|
||||
|
||||
void audio_play_attack(void) {
|
||||
void audio_play_attack(GameState *gs) {
|
||||
// Mid-range hit sound
|
||||
// play_tone(400.0f, 0.1f, 0.5f);
|
||||
int choice = GetRandomValue(1, 3);
|
||||
Sound attack;
|
||||
switch (choice) {
|
||||
case 1:
|
||||
attack = LoadSound("./assets/sounds/sword1.wav");
|
||||
PlaySound(gs->sounds.attack1);
|
||||
break;
|
||||
case 2:
|
||||
attack = LoadSound("./assets/sounds/sword2.wav");
|
||||
PlaySound(gs->sounds.attack2);
|
||||
break;
|
||||
case 3:
|
||||
attack = LoadSound("./assets/sounds/sword3.wav");
|
||||
PlaySound(gs->sounds.attack3);
|
||||
break;
|
||||
default:
|
||||
attack = LoadSound("./assets/sounds/sword1.wav");
|
||||
PlaySound(gs->sounds.attack1);
|
||||
break;
|
||||
}
|
||||
PlaySound(attack);
|
||||
}
|
||||
|
||||
void audio_play_item_pickup(void) {
|
||||
void audio_play_item_pickup(GameState *gs) {
|
||||
// High-pitched pickup sound
|
||||
play_tone(800.0f, 0.15f, 0.4f);
|
||||
Sound pickup = LoadSound("./assets/sounds/itempickup.wav");
|
||||
PlaySound(pickup);
|
||||
PlaySound(gs->sounds.pickup);
|
||||
}
|
||||
|
||||
void audio_play_enemy_death(void) {
|
||||
void audio_play_enemy_death(GameState *gs) {
|
||||
// Descending death sound
|
||||
play_tone(300.0f, 0.1f, 0.5f);
|
||||
play_tone(150.0f, 0.15f, 0.4f);
|
||||
}
|
||||
|
||||
void audio_play_player_damage(void) {
|
||||
void audio_play_player_damage(GameState *gs) {
|
||||
// Harsh damage sound
|
||||
play_tone(150.0f, 0.1f, 0.6f);
|
||||
play_tone(100.0f, 0.1f, 0.4f);
|
||||
}
|
||||
|
||||
void audio_play_stairs(void) {
|
||||
void audio_play_stairs(GameState *gs) {
|
||||
// Ascending stairs sound
|
||||
Sound staircase = LoadSound("./assets/sounds/levelcomplete.wav");
|
||||
PlaySound(staircase);
|
||||
PlaySound(gs->sounds.staircase);
|
||||
}
|
||||
|
||||
void audio_play_dodge(void) {
|
||||
void audio_play_dodge(GameState *gs) {
|
||||
// High-pitched whoosh
|
||||
// play_tone(900.0f, 0.08f, 0.3f);
|
||||
int choice = GetRandomValue(1, 3);
|
||||
Sound dodge;
|
||||
switch (choice) {
|
||||
case 1:
|
||||
dodge = LoadSound("./assets/sounds/dodge1.wav");
|
||||
PlaySound(gs->sounds.dodge1);
|
||||
break;
|
||||
case 2:
|
||||
dodge = LoadSound("./assets/sounds/dodge2.wav");
|
||||
PlaySound(gs->sounds.dodge2);
|
||||
break;
|
||||
case 3:
|
||||
dodge = LoadSound("./assets/sounds/dodge3.wav");
|
||||
PlaySound(gs->sounds.dodge3);
|
||||
break;
|
||||
default:
|
||||
dodge = LoadSound("./assets/sounds/dodge1.wav");
|
||||
PlaySound(gs->sounds.dodge1);
|
||||
break;
|
||||
}
|
||||
PlaySound(dodge);
|
||||
return;
|
||||
}
|
||||
|
||||
void audio_play_block(void) {
|
||||
void audio_play_block(GameState *gs) {
|
||||
// Low-then-mid metallic clang
|
||||
play_tone(250.0f, 0.06f, 0.5f);
|
||||
play_tone(350.0f, 0.04f, 0.3f);
|
||||
}
|
||||
|
||||
void audio_play_crit(void) {
|
||||
void audio_play_crit(GameState *gs) {
|
||||
// Sharp crack with high-pitched follow
|
||||
play_tone(600.0f, 0.05f, 0.7f);
|
||||
play_tone(900.0f, 0.1f, 0.5f);
|
||||
audio_play_attack(gs);
|
||||
PlaySound(gs->sounds.crit);
|
||||
}
|
||||
|
||||
void audio_play_proc(void) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue