diff options
Diffstat (limited to 'src/title.c')
-rw-r--r-- | src/title.c | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/src/title.c b/src/title.c new file mode 100644 index 0000000..fd57c2e --- /dev/null +++ b/src/title.c @@ -0,0 +1,72 @@ +#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; + } + } + MainCamera.zoom = GetScreenHeight()/720.0f; + 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; +} \ No newline at end of file |