Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
64adfd8a39 | ||
|
|
7bd8731cbb | ||
|
|
2fd3ee5870 | ||
|
|
59f4d6b3af |
+21
@@ -1 +1,22 @@
|
||||
# ===== Build =====
|
||||
cmake-build-*/
|
||||
build/
|
||||
out/
|
||||
|
||||
# ===== IDE =====
|
||||
.idea/
|
||||
*.iml
|
||||
|
||||
# ===== OS =====
|
||||
.DS_Store
|
||||
|
||||
# ===== Compiled =====
|
||||
*.o
|
||||
*.obj
|
||||
*.a
|
||||
*.so
|
||||
*.dylib
|
||||
*.exe
|
||||
|
||||
# ===== Logs =====
|
||||
*.log
|
||||
|
||||
Generated
+3
-1
@@ -1,4 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings" defaultProject="true" />
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
+4
-3
@@ -27,12 +27,13 @@ target_include_directories(Prog3B PRIVATE
|
||||
${CMAKE_CURRENT_LIST_DIR}/includes
|
||||
${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)
|
||||
if (APPLE)
|
||||
target_link_libraries(Prog3B PRIVATE "-framework IOKit"
|
||||
|
||||
@@ -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; }
|
||||
<<<<<<< HEAD
|
||||
float gamecube::GetRotationY() const { return rotation; }
|
||||
=======
|
||||
float gamecube::GetRotationY() const { return rotation; }
|
||||
|
||||
>>>>>>> 5fc4346 (funktioniert, 3 oder 6 + Timer komplett)
|
||||
|
||||
@@ -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]};
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
}
|
||||
=======
|
||||
}
|
||||
>>>>>>> 5fc4346 (funktioniert, 3 oder 6 + Timer komplett)
|
||||
|
||||
+52
-16
@@ -205,6 +205,8 @@ int main()
|
||||
gamecube* second = nullptr;
|
||||
float flipSpeed = 5.0f; // Drehgeschwindigkeit
|
||||
bool gameWon = false;
|
||||
int moves = 0;
|
||||
|
||||
|
||||
// Fenster und Kamera
|
||||
InitWindow(800, 600, "3D Memory Game with Matrix3D Library");
|
||||
@@ -237,6 +239,8 @@ int main()
|
||||
first = second = nullptr;
|
||||
currentScreen = GAMEPLAY;
|
||||
timerStarted = false; // Timer-Reset
|
||||
moves = 0;
|
||||
|
||||
} else if (IsKeyPressed(KEY_SIX)) {
|
||||
selectedPairs = 6; // 12 Würfel
|
||||
SetupGame(cubes, selectedPairs);
|
||||
@@ -244,6 +248,8 @@ int main()
|
||||
first = second = nullptr;
|
||||
currentScreen = GAMEPLAY;
|
||||
timerStarted = false; // Timer-Reset
|
||||
moves = 0;
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -256,36 +262,59 @@ int main()
|
||||
startTime = GetTime();
|
||||
timerStarted = true;
|
||||
}
|
||||
|
||||
// Klick-Erkennung
|
||||
if (!gameWon && IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
|
||||
// Klick-Erkennung (Ray Picking) – 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.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);
|
||||
if (fabs(mouse.x - screenPos.x) < 40 && fabs(mouse.y - screenPos.y) < 40)
|
||||
c.FlipForward();
|
||||
bestDist = col.distance;
|
||||
hitCube = &c;
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
c.Update(flipSpeed);
|
||||
if (c.IsFlipped() && !c.IsMatched())
|
||||
{
|
||||
if (!first) first = &c;
|
||||
else if (!second && &c != first) second = &c;
|
||||
}
|
||||
}
|
||||
|
||||
// Matching-Logik
|
||||
if (first && second)
|
||||
// Matching-Logik: erst wenn beide vollständig umgedreht sind
|
||||
if (first && second && first->IsFlipped() && second->IsFlipped())
|
||||
{
|
||||
moves++;
|
||||
|
||||
Color col1 = first->GetColor();
|
||||
Color col2 = second->GetColor();
|
||||
|
||||
@@ -299,7 +328,9 @@ int main()
|
||||
first->FlipBackward();
|
||||
second->FlipBackward();
|
||||
}
|
||||
first = second = nullptr;
|
||||
|
||||
first = nullptr;
|
||||
second = nullptr;
|
||||
}
|
||||
|
||||
// Gewinnprüfung
|
||||
@@ -357,6 +388,11 @@ int main()
|
||||
char liveBuf[64];
|
||||
sprintf(liveBuf, "Time: %.2f", GetTime() - startTime);
|
||||
DrawText(liveBuf, 10, 40, 20, DARKGRAY);
|
||||
|
||||
char moveBuf[64];
|
||||
snprintf(moveBuf, sizeof(moveBuf), "Moves: %d", moves);
|
||||
DrawText(moveBuf, 10, 70, 20, DARKGRAY);
|
||||
|
||||
}
|
||||
break;
|
||||
} // ENDE GAMEPLAY DRAW
|
||||
|
||||
Reference in New Issue
Block a user