about summary refs log blame commit diff stats
path: root/src/title.c
blob: d53db5a078b2cc6c25f6035996e0b247be5f17c0 (plain) (tree)
1
2
3
4
5
6
7
8
9
                 
                   




                  

                    

























                                       
                   






                                                                       





                                                          
                           


                                                         


                                                          







                                                          
                          

             









                                                         
                        
                                                                                           

                     
              
 
#include "pong.h"
#include "raylib.h"

void help_text() {

}

int title_screen() {
    // Init Camera
    Camera2D MainCamera;
    MainCamera.offset = (Vector2){0,0};
    MainCamera.target = (Vector2){0,0};
    MainCamera.rotation = 0.0f;
    bool TitleScreenGoing = true;
    play_audio(MUSIC_TITLE);
    Rectangle Versus = {
        20, 150, 230, 48
    };
    Rectangle Marathon = {
        20, 200, 230, 48
    };
    Rectangle Settings = {
        20, 250, 230, 48
    };
    Rectangle Help = {
        20, 300, 230, 48
    };
    Rectangle Exit = {
        20, 350, 230, 48
    };
    Rectangle Mouse = {
        0, 0, 10, 10
    };
    Rectangle *Selected;
    Selected = &Versus;
    EnableCursor();
    while(TitleScreenGoing == true && GameGoing == true) {
        
        if (WindowShouldClose()) { //Quit Game if the window is closed.
            GameGoing = false;
            TitleScreenGoing = false;
        }

        MainCamera.zoom = GetScreenHeight()/720.0f;
        Mouse.x = GetMouseX()/MainCamera.zoom;
        Mouse.y = GetMouseY()/MainCamera.zoom;
        if (CheckCollisionRecs(Mouse, Versus)) {
            Selected = &Versus;
            if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) {
                return(0); 
            }
        } else if (CheckCollisionRecs(Mouse, Marathon)) {
            Selected = &Marathon;
            if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) {
                return(1);
            }
        } else if (CheckCollisionRecs(Mouse, Settings)) {
            Selected = &Settings;
        } else if (CheckCollisionRecs(Mouse, Help)) {
            Selected = &Help;
        } else if (CheckCollisionRecs(Mouse, Exit)) {
            Selected = &Exit;
            if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) {
                GameGoing = false;
                return -1;
            }
        }
        BeginDrawing();
            ClearBackground(BLACK);
            BeginMode2D(MainCamera);
                DrawRectangleRec(*Selected, RED);
                DrawText("PONG", 0, 0, 128, WHITE);
                DrawText("Versus", 20, 150, 48, WHITE);
                DrawText("Marathon", 20, 200, 48, WHITE);
                DrawText("Settings", 20, 250, 48, WHITE);
                DrawText("Help", 20, 300, 48, WHITE);
                DrawText("Exit", 20, 350, 48, WHITE);
            EndMode2D();
            DrawText(VersionString, GetScreenWidth()-400, GetScreenHeight()-32, 32, GREEN);
        EndDrawing();
    }
    return -1;
}