From 2fd3ee5870364ddb156b691c5a422f1899fdc2c0 Mon Sep 17 00:00:00 2001 From: bhattial100541 Date: Sun, 14 Dec 2025 04:02:09 +0100 Subject: [PATCH] neustand mit allem final --- src/gamecube.cpp | 15 +++++++++++- src/gamematrix.cpp | 11 ++++++++- src/main.cpp | 59 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 2 deletions(-) diff --git a/src/gamecube.cpp b/src/gamecube.cpp index 274e6d5..190bf0d 100644 --- a/src/gamecube.cpp +++ b/src/gamecube.cpp @@ -1,4 +1,12 @@ +<<<<<<< HEAD #include "gamecube.h" +======= +#include "raylib.h" +#include "gamecube.h" +#pragma once + + +>>>>>>> 5fc4346 (funktioniert, 3 oder 6 + Timer komplett) gamecube::gamecube(const Vec3 &pos, Color col) : position(pos), color(col) {} @@ -63,4 +71,9 @@ void gamecube::Draw() const } Vec3 gamecube::GetPosition() const { return position; } -float gamecube::GetRotationY() const { return rotation; } \ No newline at end of file +<<<<<<< HEAD +float gamecube::GetRotationY() const { return rotation; } +======= +float gamecube::GetRotationY() const { return rotation; } + +>>>>>>> 5fc4346 (funktioniert, 3 oder 6 + Timer komplett) diff --git a/src/gamematrix.cpp b/src/gamematrix.cpp index 3a20980..3b68333 100644 --- a/src/gamematrix.cpp +++ b/src/gamematrix.cpp @@ -1,4 +1,9 @@ +<<<<<<< HEAD // +======= + + // +>>>>>>> 5fc4346 (funktioniert, 3 oder 6 + Timer komplett) // Created by bakee on 03.11.2025. // #include "gamematrix.h" @@ -94,4 +99,8 @@ namespace Matrix3D return {res_hom[0], res_hom[1], res_hom[2]}; } -} \ No newline at end of file +<<<<<<< HEAD +} +======= +} +>>>>>>> 5fc4346 (funktioniert, 3 oder 6 + Timer komplett) diff --git a/src/main.cpp b/src/main.cpp index f868f47..6bc7209 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -258,6 +258,7 @@ int main() } // Klick-Erkennung +<<<<<<< HEAD if (!gameWon && IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) { Vector2 mouse = GetMousePosition(); @@ -268,6 +269,50 @@ int main() Vector2 screenPos = GetWorldToScreen({c.GetPosition().x, c.GetPosition().y, c.GetPosition().z}, camera); if (fabs(mouse.x - screenPos.x) < 40 && fabs(mouse.y - screenPos.y) < 40) c.FlipForward(); +======= + // Klick-Erkennung (nur wenn noch nicht 2 ausgewählt sind) + if (!gameWon && IsMouseButtonPressed(MOUSE_LEFT_BUTTON) && (second == nullptr)) + { + Vector2 mouse = GetMousePosition(); + Ray ray = GetMouseRay(mouse, camera); + + gamecube* hitCube = nullptr; + float bestDist = 1e9f; + + for (auto &c : cubes) + { + if (c.IsMatched() || c.IsFlipped()) continue; + + + + + auto p = c.GetPosition(); + + + BoundingBox box; + box.min = { p.x - 0.75f, p.y - 0.75f, p.z - 0.75f }; + box.max = { p.x + 0.75f, p.y + 0.75f, p.z + 0.75f }; + + RayCollision col = GetRayCollisionBox(ray, box); + if (col.hit && col.distance < bestDist) + { + bestDist = col.distance; + hitCube = &c; + } + } + + if (hitCube) + { + if (!first) + { + first = hitCube; + first->FlipForward(); + } + else if (hitCube != first) + { + second = hitCube; + second->FlipForward(); +>>>>>>> 5fc4346 (funktioniert, 3 oder 6 + Timer komplett) } } } @@ -276,6 +321,7 @@ int main() for (auto &c : cubes) { c.Update(flipSpeed); +<<<<<<< HEAD if (c.IsFlipped() && !c.IsMatched()) { if (!first) first = &c; @@ -285,6 +331,13 @@ int main() // Matching-Logik if (first && second) +======= + } + + // Matching-Logik + // Matching-Logik: erst wenn beide vollständig umgedreht sind + if (first && second && first->IsFlipped() && second->IsFlipped()) +>>>>>>> 5fc4346 (funktioniert, 3 oder 6 + Timer komplett) { Color col1 = first->GetColor(); Color col2 = second->GetColor(); @@ -299,7 +352,13 @@ int main() first->FlipBackward(); second->FlipBackward(); } +<<<<<<< HEAD first = second = nullptr; +======= + + first = nullptr; + second = nullptr; +>>>>>>> 5fc4346 (funktioniert, 3 oder 6 + Timer komplett) } // Gewinnprüfung