added Turncount functionality

This commit is contained in:
Thomas Fischer 2025-11-29 16:47:11 +01:00
parent 5738586110
commit c9dd4958c7

View File

@ -8,6 +8,9 @@
// ----------------------------------------------------------- // -----------------------------------------------------------
int main() int main()
{ {
// Anzahl Spielzüge -> wie oft wurde ein Wuerfel geklickt
int turnCount = 0;
// Zufall initialisieren // Zufall initialisieren
srand(time(NULL)); srand(time(NULL));
@ -58,9 +61,12 @@ int main()
// ----------------------------------------------------------- // -----------------------------------------------------------
while (!WindowShouldClose()) while (!WindowShouldClose())
{ {
// Klick-Erkennung // Klick-Erkennung
if (!gameWon && IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) if (!gameWon && IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
{ {
turnCount++;
Vector2 mouse = GetMousePosition(); Vector2 mouse = GetMousePosition();
for (auto &c : cubes) for (auto &c : cubes)
@ -123,15 +129,20 @@ int main()
c.Draw(); c.Draw();
EndMode3D(); EndMode3D();
if (gameWon) if (gameWon)
DrawText("Congrats! You found all pairs!", 150, 260, 30, DARKBLUE); {
DrawText("Congrats! You found all pairs!", 150, 260, 30, DARKBLUE);
DrawText(("TurnCount: " + std::to_string(turnCount)).c_str(), 150, 290, 20, DARKBLUE);
}
else else
DrawText("Flip 2 cubes - find matching pairs!", 10, 10, 20, DARKGRAY); {
DrawText("Flip 2 cubes - find matching pairs!", 10, 10, 20, DARKGRAY);
DrawText(("TurnCount: " + std::to_string(turnCount)).c_str(), 10, 30, 20, DARKGRAY); //Zeichne TurnCount
}
EndDrawing(); EndDrawing();
} }
CloseWindow(); CloseWindow();
return 0; return 0;
} }