menu
This commit is contained in:
parent
7cc1d0cbfd
commit
a01ce2256e
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
@ -1,19 +1,20 @@
|
|||||||
#include "gamecube.h"
|
#include "gamecube.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
#include <menu.h>
|
||||||
|
|
||||||
// -----------------------------------------------------------
|
// -----------------------------------------------------------
|
||||||
// 3D Memory Game – Hauptprogramm
|
// 3D Memory Game – Hauptprogramm
|
||||||
// -----------------------------------------------------------
|
// -----------------------------------------------------------
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// Zufall initialisieren
|
|
||||||
srand(time(NULL));
|
|
||||||
|
|
||||||
// Fenster und Kamera
|
// Fenster und Kamera
|
||||||
InitWindow(800, 600, "3D Memory Game with Matrix3D Library");
|
InitWindow(800, 600, "3D Memory Game with Matrix3D Library");
|
||||||
SetTargetFPS(60);
|
SetTargetFPS(60);
|
||||||
|
|
||||||
|
// Zufall initialisieren
|
||||||
|
srand(time(NULL));
|
||||||
|
|
||||||
Camera3D camera{};
|
Camera3D camera{};
|
||||||
camera.position = {6.0f, 6.0f, 6.0f};
|
camera.position = {6.0f, 6.0f, 6.0f};
|
||||||
camera.target = {0.0f, 0.0f, 0.0f};
|
camera.target = {0.0f, 0.0f, 0.0f};
|
||||||
@ -24,6 +25,7 @@ int main()
|
|||||||
// Nur 3 Farben für 3 Paare
|
// Nur 3 Farben für 3 Paare
|
||||||
Color colors[] = { RED, GREEN, BLUE };
|
Color colors[] = { RED, GREEN, BLUE };
|
||||||
|
|
||||||
|
|
||||||
// 6 Karten-Positionen im 3x2 Raster
|
// 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}};
|
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
|
float flipSpeed = 5.0f; // Drehgeschwindigkeit
|
||||||
bool gameWon = false;
|
bool gameWon = false;
|
||||||
|
|
||||||
// -----------------------------------------------------------
|
enum GameState { MENU, GAME };
|
||||||
// Hauptspielschleife
|
GameState state = MENU;
|
||||||
// -----------------------------------------------------------
|
|
||||||
while (!WindowShouldClose())
|
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
|
// Klick-Erkennung
|
||||||
if (!gameWon && IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
|
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