about summary refs log tree commit diff stats
path: root/src/title.c
blob: d53db5a078b2cc6c25f6035996e0b247be5f17c0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#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;
}