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;
|
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,21 +262,7 @@ int main()
|
|||||||
startTime = GetTime();
|
startTime = GetTime();
|
||||||
timerStarted = true;
|
timerStarted = true;
|
||||||
}
|
}
|
||||||
|
// Klick-Erkennung (Ray Picking) – nur wenn noch nicht 2 ausgewählt sind
|
||||||
// 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)
|
|
||||||
if (!gameWon && IsMouseButtonPressed(MOUSE_LEFT_BUTTON) && (second == nullptr))
|
if (!gameWon && IsMouseButtonPressed(MOUSE_LEFT_BUTTON) && (second == nullptr))
|
||||||
{
|
{
|
||||||
Vector2 mouse = GetMousePosition();
|
Vector2 mouse = GetMousePosition();
|
||||||
@ -283,11 +275,7 @@ int main()
|
|||||||
{
|
{
|
||||||
if (c.IsMatched() || c.IsFlipped()) continue;
|
if (c.IsMatched() || c.IsFlipped()) continue;
|
||||||
|
|
||||||
|
Vec3 p = c.GetPosition();
|
||||||
|
|
||||||
|
|
||||||
auto p = c.GetPosition();
|
|
||||||
|
|
||||||
|
|
||||||
BoundingBox box;
|
BoundingBox box;
|
||||||
box.min = { p.x - 0.75f, p.y - 0.75f, p.z - 0.75f };
|
box.min = { p.x - 0.75f, p.y - 0.75f, p.z - 0.75f };
|
||||||
@ -312,33 +300,21 @@ int main()
|
|||||||
{
|
{
|
||||||
second = hitCube;
|
second = hitCube;
|
||||||
second->FlipForward();
|
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)
|
for (auto &c : cubes)
|
||||||
{
|
{
|
||||||
c.Update(flipSpeed);
|
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
|
// Matching-Logik: erst wenn beide vollständig umgedreht sind
|
||||||
if (first && second && first->IsFlipped() && second->IsFlipped())
|
if (first && second && first->IsFlipped() && second->IsFlipped())
|
||||||
>>>>>>> 5fc4346 (funktioniert, 3 oder 6 + Timer komplett)
|
|
||||||
{
|
{
|
||||||
|
moves++;
|
||||||
|
|
||||||
Color col1 = first->GetColor();
|
Color col1 = first->GetColor();
|
||||||
Color col2 = second->GetColor();
|
Color col2 = second->GetColor();
|
||||||
|
|
||||||
@ -352,13 +328,9 @@ int main()
|
|||||||
first->FlipBackward();
|
first->FlipBackward();
|
||||||
second->FlipBackward();
|
second->FlipBackward();
|
||||||
}
|
}
|
||||||
<<<<<<< HEAD
|
|
||||||
first = second = nullptr;
|
|
||||||
=======
|
|
||||||
|
|
||||||
first = nullptr;
|
first = nullptr;
|
||||||
second = nullptr;
|
second = nullptr;
|
||||||
>>>>>>> 5fc4346 (funktioniert, 3 oder 6 + Timer komplett)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gewinnprüfung
|
// Gewinnprüfung
|
||||||
@ -416,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
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user