about summary refs log tree commit diff stats
path: root/src/title.c
blob: 1f2a51d21b61d4343d2ea35ecfe67d27f120a517 (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
#include "pong.h"

void help_text() {

}

void title_screen() {
    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;
    while(!WindowShouldClose() && TitleScreenGoing == true) {
        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; 
            }
        } else if (CheckCollisionRecs(Mouse, Marathon)) {
            Selected = &Marathon;
        } 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;
            }
        }
        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);
                DrawRectangleRec(Mouse, YELLOW);
            EndMode2D();
        EndDrawing();
    }
    return;
}