diff --git a/raylib/menu.h b/raylib/menu.h new file mode 100644 index 0000000..87e497b --- /dev/null +++ b/raylib/menu.h @@ -0,0 +1,19 @@ + +#ifndef MENU_H +#define MENU_H + +#pragma once +#include "raylib.h" + +enum MenuResult { + MENU_NONE, + MENU_SELECT_3, + MENU_SELECT_6, + MENU_SELECT_9 +}; + +MenuResult DrawMenu(); + +#endif //MENU_H + + diff --git a/src/main.cpp b/src/main.cpp index 287251d..0932a0d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,19 +1,20 @@ #include "gamecube.h" #include #include +#include // ----------------------------------------------------------- // 3D Memory Game – Hauptprogramm // ----------------------------------------------------------- int main() { - // Zufall initialisieren - srand(time(NULL)); - // Fenster und Kamera InitWindow(800, 600, "3D Memory Game with Matrix3D Library"); SetTargetFPS(60); + // Zufall initialisieren + srand(time(NULL)); + Camera3D camera{}; camera.position = {6.0f, 6.0f, 6.0f}; camera.target = {0.0f, 0.0f, 0.0f}; @@ -24,6 +25,7 @@ int main() // Nur 3 Farben für 3 Paare Color colors[] = { RED, GREEN, BLUE }; + // 6 Karten-Positionen im 3x2 Raster std::vector positions = {{-2, 0, -2}, {0, 0, -2}, {2, 0, -2},{-2, 0, 0}, {0, 0, 0}, {2, 0, 0}}; @@ -52,11 +54,27 @@ int main() float flipSpeed = 5.0f; // Drehgeschwindigkeit bool gameWon = false; - // ----------------------------------------------------------- - // Hauptspielschleife - // ----------------------------------------------------------- - while (!WindowShouldClose()) - { + enum GameState { MENU, GAME }; + GameState state = MENU; + + int pairCount = 3; + + while (!WindowShouldClose()) { + + if (state == MENU) { + MenuResult res = DrawMenu(); + + switch (res) { + case MENU_SELECT_3: pairCount = 3; state = GAME; break; + case MENU_SELECT_6: pairCount = 6; state = GAME; break; + case MENU_SELECT_9: pairCount = 9; state = GAME; break; + default: break; + } + + continue; + } + + // === GAME === // Klick-Erkennung if (!gameWon && IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) { diff --git a/src/menu.cpp b/src/menu.cpp new file mode 100644 index 0000000..9128be2 --- /dev/null +++ b/src/menu.cpp @@ -0,0 +1,32 @@ +#include "menu.h" + +MenuResult DrawMenu() { + Rectangle b1 = { 250, 180, 300, 50 }; + Rectangle b2 = { 250, 260, 300, 50 }; + Rectangle b3 = { 250, 340, 300, 50 }; + + BeginDrawing(); + ClearBackground(RAYWHITE); + + DrawText("Wähle Anzahl Paare:", 200, 100, 30, DARKGRAY); + + DrawRectangleRec(b1, LIGHTGRAY); + DrawText("3 Paare", 340, 195, 20, BLACK); + + DrawRectangleRec(b2, LIGHTGRAY); + DrawText("6 Paare", 340, 275, 20, BLACK); + + DrawRectangleRec(b3, LIGHTGRAY); + DrawText("9 Paare", 340, 355, 20, BLACK); + + EndDrawing(); + + Vector2 m = GetMousePosition(); + if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) { + if (CheckCollisionPointRec(m, b1)) return MENU_SELECT_3; + if (CheckCollisionPointRec(m, b2)) return MENU_SELECT_6; + if (CheckCollisionPointRec(m, b3)) return MENU_SELECT_9; + } + + return MENU_NONE; +}