added playtime functionality
This commit is contained in:
parent
c9dd4958c7
commit
3c7ae2a9b3
14
src/main.cpp
14
src/main.cpp
@ -11,6 +11,12 @@ int main()
|
||||
// Anzahl Spielzüge -> wie oft wurde ein Wuerfel geklickt
|
||||
int turnCount = 0;
|
||||
|
||||
// Startzeit für timer berechnung -> aktueller Zeitpunkt in Sekunden
|
||||
time_t startTime = time(nullptr);
|
||||
|
||||
// gespielte Zeit
|
||||
int playTime = 0;
|
||||
|
||||
// Zufall initialisieren
|
||||
srand(time(NULL));
|
||||
|
||||
@ -61,7 +67,11 @@ int main()
|
||||
// -----------------------------------------------------------
|
||||
while (!WindowShouldClose())
|
||||
{
|
||||
|
||||
// die aktuelle Spielzeit berechnen
|
||||
if (!gameWon)
|
||||
{
|
||||
playTime = static_cast<int>(time(nullptr) - startTime);
|
||||
}
|
||||
|
||||
// Klick-Erkennung
|
||||
if (!gameWon && IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
|
||||
@ -134,11 +144,13 @@ int main()
|
||||
{
|
||||
DrawText("Congrats! You found all pairs!", 150, 260, 30, DARKBLUE);
|
||||
DrawText(("TurnCount: " + std::to_string(turnCount)).c_str(), 150, 290, 20, DARKBLUE);
|
||||
DrawText(("Seconds played: " + std::to_string(playTime)).c_str(), 150, 310, 20, DARKBLUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
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
|
||||
DrawText(("PlayTime: " + std::to_string(playTime)).c_str(), 10, 50, 20, DARKGRAY); //Zeichne Playtime
|
||||
}
|
||||
EndDrawing();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user