Merge branch 'master' of ssh.marcbarbier.fr:Marc/gamejam-polytech

This commit is contained in:
Marc
2023-01-22 17:19:10 +01:00
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;
@@ -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);