Merge branch 'menu'
This commit is contained in:
commit
8eda1730bf
@ -14,6 +14,6 @@ public:
|
||||
// Rotationsmatrix um Achse x/y/z
|
||||
static std::array<std::array<double,4>,4> rot3D(double angle_deg, char axis);
|
||||
|
||||
// Verschiebung
|
||||
// std::array<std::array<double,4>,4>
|
||||
static std::array<std::array<double,4>,4> translate(const std::array<double, 3>& pos);
|
||||
};
|
||||
|
||||
19
raylib/menu.h
Normal file
19
raylib/menu.h
Normal 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
|
||||
|
||||
|
||||
34
src/main.cpp
34
src/main.cpp
@ -2,15 +2,13 @@
|
||||
#include "gametimer.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);
|
||||
@ -18,6 +16,9 @@ int main()
|
||||
Timer timer;
|
||||
timer.start();
|
||||
|
||||
// Zufall initialisieren
|
||||
srand(time(NULL));
|
||||
|
||||
Camera3D camera{};
|
||||
camera.position = {6.0f, 6.0f, 6.0f};
|
||||
camera.target = {0.0f, 0.0f, 0.0f};
|
||||
@ -28,6 +29,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}};
|
||||
|
||||
@ -56,11 +58,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
32
src/menu.cpp
Normal 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;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user