Author SHA1 Message Date
bhattial100541 64adfd8a39 .. 2025-12-15 12:03:00 +01:00
bhattial100541 7bd8731cbb Puntestand einbauen 2025-12-14 04:34:32 +01:00
bhattial100541 2fd3ee5870 neustand mit allem final 2025-12-14 04:02:09 +01:00
bhattial100541 59f4d6b3af .gitignore aktualiesiert 2025-12-13 22:33:58 +01:00
6 changed files with 104 additions and 22 deletions
+21
View File
@@ -1 +1,22 @@
# ===== Build =====
cmake-build-*/
build/
out/
# ===== IDE =====
.idea/ .idea/
*.iml
# ===== OS =====
.DS_Store
# ===== Compiled =====
*.o
*.obj
*.a
*.so
*.dylib
*.exe
# ===== Logs =====
*.log
Generated
+3 -1
View File
@@ -1,4 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="VcsDirectoryMappings" defaultProject="true" /> <component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project> </project>
+4 -3
View File
@@ -27,12 +27,13 @@ target_include_directories(Prog3B PRIVATE
${CMAKE_CURRENT_LIST_DIR}/includes ${CMAKE_CURRENT_LIST_DIR}/includes
${CMAKE_CURRENT_LIST_DIR}/raylib ${CMAKE_CURRENT_LIST_DIR}/raylib
) )
target_link_libraries(${EXECUTABLE_NAME} PRIVATE
#${CMAKE_CURRENT_LIST_DIR}/windows/libgamematrix.a
${CMAKE_CURRENT_LIST_DIR}/mac_arm/libraylib.a
target_link_libraries(${EXECUTABLE_NAME} PRIVATE
${CMAKE_CURRENT_LIST_DIR}/mac_x86/libgamematrix.a
raylib
) )
# Checks if OSX and links appropriate frameworks (Only required on MacOS) # Checks if OSX and links appropriate frameworks (Only required on MacOS)
if (APPLE) if (APPLE)
target_link_libraries(Prog3B PRIVATE "-framework IOKit" target_link_libraries(Prog3B PRIVATE "-framework IOKit"
+13
View File
@@ -1,4 +1,12 @@
<<<<<<< HEAD
#include "gamecube.h" #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) gamecube::gamecube(const Vec3 &pos, Color col)
: position(pos), color(col) {} : position(pos), color(col) {}
@@ -63,4 +71,9 @@ void gamecube::Draw() const
} }
Vec3 gamecube::GetPosition() const { return position; } Vec3 gamecube::GetPosition() const { return position; }
<<<<<<< HEAD
float gamecube::GetRotationY() const { return rotation; } float gamecube::GetRotationY() const { return rotation; }
=======
float gamecube::GetRotationY() const { return rotation; }
>>>>>>> 5fc4346 (funktioniert, 3 oder 6 + Timer komplett)
+9
View File
@@ -1,4 +1,9 @@
<<<<<<< HEAD
// //
=======
//
>>>>>>> 5fc4346 (funktioniert, 3 oder 6 + Timer komplett)
// Created by bakee on 03.11.2025. // Created by bakee on 03.11.2025.
// //
#include "gamematrix.h" #include "gamematrix.h"
@@ -94,4 +99,8 @@ namespace Matrix3D
return {res_hom[0], res_hom[1], res_hom[2]}; return {res_hom[0], res_hom[1], res_hom[2]};
} }
<<<<<<< HEAD
} }
=======
}
>>>>>>> 5fc4346 (funktioniert, 3 oder 6 + Timer komplett)
+52 -16
View File
@@ -205,6 +205,8 @@ int main()
gamecube* second = nullptr; gamecube* second = nullptr;
float flipSpeed = 5.0f; // Drehgeschwindigkeit float flipSpeed = 5.0f; // Drehgeschwindigkeit
bool gameWon = false; bool gameWon = false;
int moves = 0;
// Fenster und Kamera // Fenster und Kamera
InitWindow(800, 600, "3D Memory Game with Matrix3D Library"); InitWindow(800, 600, "3D Memory Game with Matrix3D Library");
@@ -237,6 +239,8 @@ int main()
first = second = nullptr; first = second = nullptr;
currentScreen = GAMEPLAY; currentScreen = GAMEPLAY;
timerStarted = false; // Timer-Reset timerStarted = false; // Timer-Reset
moves = 0;
} else if (IsKeyPressed(KEY_SIX)) { } else if (IsKeyPressed(KEY_SIX)) {
selectedPairs = 6; // 12 Würfel selectedPairs = 6; // 12 Würfel
SetupGame(cubes, selectedPairs); SetupGame(cubes, selectedPairs);
@@ -244,6 +248,8 @@ int main()
first = second = nullptr; first = second = nullptr;
currentScreen = GAMEPLAY; currentScreen = GAMEPLAY;
timerStarted = false; // Timer-Reset timerStarted = false; // Timer-Reset
moves = 0;
} }
break; break;
} }
@@ -256,36 +262,59 @@ int main()
startTime = GetTime(); startTime = GetTime();
timerStarted = true; timerStarted = true;
} }
// Klick-Erkennung (Ray Picking) – nur wenn noch nicht 2 ausgewählt sind
// Klick-Erkennung if (!gameWon && IsMouseButtonPressed(MOUSE_LEFT_BUTTON) && (second == nullptr))
if (!gameWon && IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
{ {
Vector2 mouse = GetMousePosition(); Vector2 mouse = GetMousePosition();
Ray ray = GetMouseRay(mouse, camera);
gamecube* hitCube = nullptr;
float bestDist = 1e9f;
for (auto &c : cubes) for (auto &c : cubes)
{ {
if (!c.IsFlipped() && !c.IsMatched()) if (c.IsMatched() || c.IsFlipped()) continue;
Vec3 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)
{ {
Vector2 screenPos = GetWorldToScreen({c.GetPosition().x, c.GetPosition().y, c.GetPosition().z}, camera); bestDist = col.distance;
if (fabs(mouse.x - screenPos.x) < 40 && fabs(mouse.y - screenPos.y) < 40) hitCube = &c;
c.FlipForward(); }
}
if (hitCube)
{
if (!first)
{
first = hitCube;
first->FlipForward();
}
else if (hitCube != first)
{
second = hitCube;
second->FlipForward();
} }
} }
} }
// Animation aller Würfel // Animation aller Würfel (KEINE first/second Auto-Zuweisung hier!)
for (auto &c : cubes) for (auto &c : cubes)
{ {
c.Update(flipSpeed); c.Update(flipSpeed);
if (c.IsFlipped() && !c.IsMatched())
{
if (!first) first = &c;
else if (!second && &c != first) second = &c;
}
} }
// Matching-Logik // Matching-Logik: erst wenn beide vollständig umgedreht sind
if (first && second) if (first && second && first->IsFlipped() && second->IsFlipped())
{ {
moves++;
Color col1 = first->GetColor(); Color col1 = first->GetColor();
Color col2 = second->GetColor(); Color col2 = second->GetColor();
@@ -299,7 +328,9 @@ int main()
first->FlipBackward(); first->FlipBackward();
second->FlipBackward(); second->FlipBackward();
} }
first = second = nullptr;
first = nullptr;
second = nullptr;
} }
// Gewinnprüfung // Gewinnprüfung
@@ -357,6 +388,11 @@ int main()
char liveBuf[64]; char liveBuf[64];
sprintf(liveBuf, "Time: %.2f", GetTime() - startTime); sprintf(liveBuf, "Time: %.2f", GetTime() - startTime);
DrawText(liveBuf, 10, 40, 20, DARKGRAY); DrawText(liveBuf, 10, 40, 20, DARKGRAY);
char moveBuf[64];
snprintf(moveBuf, sizeof(moveBuf), "Moves: %d", moves);
DrawText(moveBuf, 10, 70, 20, DARKGRAY);
} }
break; break;
} // ENDE GAMEPLAY DRAW } // ENDE GAMEPLAY DRAW