Compare commits
2 Commits
main
...
Punktestan
| Author | SHA1 | Date | |
|---|---|---|---|
| 64adfd8a39 | |||
| 7bd8731cbb |
55
src/main.cpp
55
src/main.cpp
@ -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,21 +262,7 @@ int main()
|
||||
startTime = GetTime();
|
||||
timerStarted = true;
|
||||
}
|
||||
|
||||
// Klick-Erkennung
|
||||
<<<<<<< HEAD
|
||||
if (!gameWon && IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
|
||||
{
|
||||
Vector2 mouse = GetMousePosition();
|
||||
for (auto &c : cubes)
|
||||
{
|
||||
if (!c.IsFlipped() && !c.IsMatched())
|
||||
{
|
||||
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)
|
||||
// Klick-Erkennung (Ray Picking) – nur wenn noch nicht 2 ausgewählt sind
|
||||
if (!gameWon && IsMouseButtonPressed(MOUSE_LEFT_BUTTON) && (second == nullptr))
|
||||
{
|
||||
Vector2 mouse = GetMousePosition();
|
||||
@ -283,11 +275,7 @@ int main()
|
||||
{
|
||||
if (c.IsMatched() || c.IsFlipped()) continue;
|
||||
|
||||
|
||||
|
||||
|
||||
auto p = c.GetPosition();
|
||||
|
||||
Vec3 p = c.GetPosition();
|
||||
|
||||
BoundingBox box;
|
||||
box.min = { p.x - 0.75f, p.y - 0.75f, p.z - 0.75f };
|
||||
@ -312,33 +300,21 @@ int main()
|
||||
{
|
||||
second = hitCube;
|
||||
second->FlipForward();
|
||||
>>>>>>> 5fc4346 (funktioniert, 3 oder 6 + Timer komplett)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Animation aller Würfel
|
||||
// Animation aller Würfel (KEINE first/second Auto-Zuweisung hier!)
|
||||
for (auto &c : cubes)
|
||||
{
|
||||
c.Update(flipSpeed);
|
||||
<<<<<<< HEAD
|
||||
if (c.IsFlipped() && !c.IsMatched())
|
||||
{
|
||||
if (!first) first = &c;
|
||||
else if (!second && &c != first) second = &c;
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
moves++;
|
||||
|
||||
Color col1 = first->GetColor();
|
||||
Color col2 = second->GetColor();
|
||||
|
||||
@ -352,13 +328,9 @@ int main()
|
||||
first->FlipBackward();
|
||||
second->FlipBackward();
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
first = second = nullptr;
|
||||
=======
|
||||
|
||||
first = nullptr;
|
||||
second = nullptr;
|
||||
>>>>>>> 5fc4346 (funktioniert, 3 oder 6 + Timer komplett)
|
||||
}
|
||||
|
||||
// Gewinnprüfung
|
||||
@ -416,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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user