diff --git a/assets/music/ko-effect-gain.mp3 b/assets/music/ko-effect-gain.mp3 new file mode 100644 index 0000000..2cc672b Binary files /dev/null and b/assets/music/ko-effect-gain.mp3 differ diff --git a/assets/music/ko-effect.mp3 b/assets/music/ko-effect.mp3 new file mode 100644 index 0000000..03c1c09 Binary files /dev/null and b/assets/music/ko-effect.mp3 differ diff --git a/assets/music/pet.mp3 b/assets/music/pet.mp3 index 1b1da82..3740cf6 100644 Binary files a/assets/music/pet.mp3 and b/assets/music/pet.mp3 differ diff --git a/src/game.c b/src/game.c index 5079cd1..378a0c2 100644 --- a/src/game.c +++ b/src/game.c @@ -16,6 +16,9 @@ #define GRAVITY 10000.f static Mix_Music * music; +static Mix_Chunk * petMusic; +static Mix_Chunk * koMusic; + Scene_t gameScene; @@ -68,7 +71,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); @@ -87,6 +90,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()); @@ -312,6 +327,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);