This commit is contained in:
Bendit Straetemans 2025-12-08 16:04:03 +01:00
parent 7cc1d0cbfd
commit a01ce2256e
3 changed files with 77 additions and 8 deletions

19
raylib/menu.h Normal file
View File

@ -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

View File

@ -1,19 +1,20 @@
#include "gamecube.h"
#include <algorithm>
#include <ctime>
#include <menu.h>
// -----------------------------------------------------------
// 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<Vec3> 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))
{

32
src/menu.cpp Normal file
View File

@ -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;
}