add audio effects

This commit is contained in:
2023-01-22 17:18:36 +01:00
parent b5fda06f31
commit 2f266c7949
4 changed files with 30 additions and 1 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
+30 -1
View File
@@ -16,6 +16,9 @@
#define GRAVITY 10000.f
static Mix_Music * music;
static Mix_Chunk * petMusic;
static Mix_Chunk * koMusic;
Scene_t gameScene;
@@ -69,7 +72,7 @@ static RenderId_t strengthBarSliderId;
static bool increaseStrengthBarSlider = true;
#define STEROIDS_POSITION CAMERA_WIDTH * 0.4f
#define SLIDER_SPEED (1.f/5000 / (adameStrength *0.5f))
#define SLIDER_SPEED ((adameStrength *0.5f)/5000)
void game_handleFKeyInput(void);
@@ -83,6 +86,18 @@ static void playMusic(){
exit(1);
}
petMusic = Mix_LoadWAV("./assets/music/pet.mp3");
if(petMusic == NULL){
fprintf(stderr, "Pet audio not found!\n");
exit(1);
}
koMusic = Mix_LoadWAV("./assets/music/ko-effect-gain.mp3");
if(koMusic == NULL){
fprintf(stderr, "ko effect audio not found!\n");
exit(1);
}
if(Mix_PlayMusic(music, 0) != 0){
printf("Music sound could not be played!\n"
"SDL_Error: %s\n", Mix_GetError());
@@ -300,6 +315,20 @@ int game_render(float delta){
scene_moveRenderObject(&gameScene, adame[0], ADAME_X, ADAME_Y);
adame_id = 0;
kicked = true;
if(strength > 1.5){
if(Mix_PlayChannel(-1, koMusic, 0) != 0){
printf("Music sound could not be played!\n"
"SDL_Error: %s\n", Mix_GetError());
Mix_FreeChunk(koMusic);
}
}
else{
if(Mix_PlayChannel(-1, petMusic, 0) != 0){
printf("Music sound could not be played!\n"
"SDL_Error: %s\n", Mix_GetError());
Mix_FreeChunk(petMusic);
}
}
} else {
adame_id++;
scene_moveRenderObject(&gameScene, adame[adame_id], ADAME_X, ADAME_Y);