about summary refs log tree commit diff stats
path: root/src/title.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/title.c')
-rw-r--r--src/title.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/title.c b/src/title.c
index 3e85a96..2f8148d 100644
--- a/src/title.c
+++ b/src/title.c
@@ -13,8 +13,11 @@ int title_screen() {
     MainCamera.offset = (Vector2){0,0};
     MainCamera.target = (Vector2){0,0};
     MainCamera.rotation = 0.0f;
+
     bool TitleScreenGoing = true;
-    play_audio(MUSIC_TITLE);
+    int Choice = 0;
+
+    // Selection
     Rectangle Versus = {
         20, 150, 230, 48
     };
@@ -36,6 +39,12 @@ int title_screen() {
     Rectangle *Selected;
     Selected = &Versus;
     EnableCursor();
+
+    //Music
+    Mix_Music *TitleMusic = Mix_LoadMUS("resources/title.wav");
+    Mix_PlayMusic(TitleMusic, 1);
+    Mix_VolumeMusic(GlobalSettings.MusicVolume);
+
     while(TitleScreenGoing == true && GameGoing == true) {
         
         if (WindowShouldClose()) { //Quit Game if the window is closed.
@@ -49,12 +58,14 @@ int title_screen() {
         if (CheckCollisionRecs(Mouse, Versus)) {
             Selected = &Versus;
             if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) {
-                return(0); 
+                Choice = 0;
+                TitleScreenGoing = false;
             }
         } else if (CheckCollisionRecs(Mouse, Marathon)) {
             Selected = &Marathon;
             if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) {
-                return(1);
+                Choice = 1;
+                TitleScreenGoing = false;
             }
         } else if (CheckCollisionRecs(Mouse, Settings)) {
             Selected = &Settings;
@@ -81,5 +92,7 @@ int title_screen() {
             DrawText(VersionString, GetScreenWidth()-400, GetScreenHeight()-32, 32, GREEN);
         EndDrawing();
     }
-    return -1;
+    Mix_HaltMusic();
+    Mix_FreeMusic(TitleMusic);
+    return Choice;
 }