diff options
Diffstat (limited to 'src/versus.c')
-rw-r--r-- | src/versus.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/versus.c b/src/versus.c index cd57d9a..233b238 100644 --- a/src/versus.c +++ b/src/versus.c @@ -1,5 +1,7 @@ #include "pong.h" #include "raylib.h" +#include "sounds.h" +#include <SDL2/SDL_mixer.h> void versus_main() { // Init Player Variables @@ -22,9 +24,9 @@ void versus_main() { Ball.Angle = 0.0f; // Init music - Music Background = LoadMusicStream("resources/versus.wav"); - Background.looping = true; - PlayMusicStream(Background); + Mix_Music *Background = Mix_LoadMUS("resources/versus.wav"); + Mix_PlayMusic(Background, -1); + Mix_VolumeMusic(MIX_MAX_VOLUME); // Set Sprites Texture2D PaddleSprite = LoadTexture("resources/paddle.png"); @@ -49,14 +51,15 @@ void versus_main() { GameGoing = false; } - UpdateMusicStream(Background); MainCamera.zoom = GetScreenHeight()/720.0f; MainCamera.offset = (Vector2){GetScreenWidth()/2.0f, GetScreenHeight()/2.0f}; MainCamera.target = (Vector2){1280/2.0f, 720/2.0f}; // Who won? if (Enemy.Score >= 5) { - StopSoundMulti(); + Mix_HaltMusic(); + Mix_FreeMusic(Background); + play_audio(STOP_ALL_SOUNDS); play_audio(MUSIC_DEFEAT); while(!IsKeyDown(KEY_SPACE)) { BeginDrawing(); @@ -68,7 +71,9 @@ void versus_main() { } return; } else if (Player.Score >= 5) { - StopSoundMulti(); + Mix_HaltMusic(); + Mix_FreeMusic(Background); + play_audio(STOP_ALL_SOUNDS); play_audio(MUSIC_VICTORY); while(!IsKeyDown(KEY_SPACE)) { BeginDrawing(); @@ -95,7 +100,7 @@ void versus_main() { // Leave Game if(IsKeyPressed(KEY_Q)) { - return; + VersusGoing = false; } if(GetMouseY() < 0) { @@ -135,5 +140,9 @@ void versus_main() { EndMode2D(); EndDrawing(); } + + Mix_HaltMusic(); + Mix_FreeMusic(Background); + play_audio(STOP_ALL_SOUNDS); return; } |