Zähler eingebaut und versucht highscore zu fixen

Zähler eingebaut und versucht highscore zu fixen
This commit is contained in:
marcelbls 2025-12-01 13:11:11 +01:00
parent aa5ca11829
commit c6cdebfc84
5 changed files with 27 additions and 17 deletions

15
.idea/workspace.xml generated
View File

@ -7,6 +7,7 @@
<option name="/Default/RiderDebugger/RiderRestoreDecompile/RestoreDecompileSetting/@EntryValue" value="false" type="bool" />
<option name="/Default/Housekeeping/GlobalSettingsUpgraded/IsUpgraded/@EntryValue" value="true" type="bool" />
<option name="/Default/Housekeeping/FeatureSuggestion/FeatureSuggestionManager/DisabledSuggesters/=SwitchToGoToActionSuggester/@EntryIndexedValue" value="true" type="bool" />
<option name="/Default/Housekeeping/FeatureSuggestion/FeatureSuggestionManager/DisabledSuggesters/=SwitchToGoToActionSuggester/@EntryIndexRemoved" />
</component>
<component name="CMakePresetLoader">{
&quot;useNewFormat&quot;: true
@ -30,12 +31,11 @@
</component>
<component name="ChangeListManager">
<list default="true" id="db070755-9708-4a46-a9cb-e7c4dc1bfb77" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/Highscores.txt" afterDir="false" />
<change afterPath="$PROJECT_DIR$/ScoreManager.cpp" afterDir="false" />
<change afterPath="$PROJECT_DIR$/ScoreManager.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/CMakeLists.txt" beforeDir="false" afterPath="$PROJECT_DIR$/CMakeLists.txt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Highscores.txt" beforeDir="false" afterPath="$PROJECT_DIR$/Highscores.txt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ScoreManager.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/ScoreManager.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/main.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/userinterface.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/userinterface.cpp" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -87,7 +87,7 @@
"RunOnceActivity.west.config.association.type.startup.service": "true",
"cf.first.check.clang-format": "false",
"cidr.known.project.marker": "true",
"git-widget-placeholder": "main",
"git-widget-placeholder": "Zeit__zaeler",
"last_opened_file_path": "C:/Desktop/StudiumME/3.Sem/Prog3/B/MatrixPybind",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
@ -98,11 +98,6 @@
}
}]]></component>
<component name="RunManager" selected="CMake Application.Prog3B">
<configuration default="true" type="CLionExternalRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" PASS_PARENT_ENVS_2="true">
<method v="2">
<option name="CLION.EXTERNAL.BUILD" enabled="true" />
</method>
</configuration>
<configuration name="Prog3B" type="CMakeRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="Prog3B" TARGET_NAME="Prog3B" CONFIG_NAME="Debug" RUN_TARGET_PROJECT_NAME="Prog3B" RUN_TARGET_NAME="Prog3B">
<method v="2">
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />

View File

@ -0,0 +1 @@
11.34

View File

@ -5,6 +5,7 @@
ScoreManager::ScoreManager(const std::string& filename) : highscoreFile(filename)
{
std::cout << "test";
loadHighscore();
}
@ -23,8 +24,6 @@ void ScoreManager::loadHighscore() {
void ScoreManager::incrementScore() {
currentScore++;
}
void ScoreManager::resetScore() {

View File

@ -3,6 +3,8 @@
#include "userinterface.h"
#include <algorithm>
#include <ctime>
#include <iostream>
#include "ScoreManager.h"
// -----------------------------------------------------------
@ -30,20 +32,23 @@ int main()
camera.projection = CAMERA_PERSPECTIVE;
//TODO: Hier die Zeit abrufen.
double currentScoreTime = 11.42;
double highScoreTime = 15.41;
double currentScoreTime = 0.0;
double startTime = 0.0;
double highScoreTime = 43.4;
//TODO: Hier die Anzahl der Züge abrufen.
int currentScoreTurns = 0;
int highScoreTurns = score.getHighScore();
if (currentScoreTime <= highScoreTime) highScoreTime = currentScoreTime;
if (currentScoreTime <= highScoreTurns) highScoreTurns = currentScoreTurns;
//if (currentScoreTime <= highScoreTime) highScoreTime = currentScoreTime;
//if (currentScoreTime <= highScoreTurns) highScoreTurns = currentScoreTurns;
int cubePairs = userInterface.getCubeCount();
if (cubePairs <= 0) {
userInterface.showMenu(currentScoreTime, highScoreTime, currentScoreTurns, highScoreTurns);
cubePairs = userInterface.getCubeCount();
// Startzeit speichern nach Enter
startTime = currentScoreTime;
}
std::vector<Vec3> positions =createCubes(cubePairs);
@ -143,6 +148,12 @@ int main()
if (!gameWon)
gameWon = std::all_of(cubes.begin(), cubes.end(), [](const gamecube &c){ return c.IsMatched(); });
//Zeit Berechnung
if (!gameWon)
{
currentScoreTime = GetTime() - startTime;
DrawText(TextFormat("%.2f", currentScoreTime), 10, 30, 20, DARKGRAY);
}
// -----------------------------------------------------------
// Zeichnen
// -----------------------------------------------------------
@ -163,14 +174,16 @@ int main()
//TODO: Neue Scores zuweisen, current genügen.
//currentScoreTime = 17.3;
//currentScoreTurns = 10;
score.saveHighScore();
if (currentScoreTime <= highScoreTime) highScoreTime = currentScoreTime;
if (currentScoreTurns <= highScoreTurns) highScoreTurns = currentScoreTurns;
score.saveHighScore();
userInterface.showScore(currentScoreTime, highScoreTime, currentScoreTurns, highScoreTurns);
}
else
DrawText("Flip 2 cubes - find matching pairs!", 10, 10, 20, DARKGRAY);
EndDrawing();
}

View File

@ -32,6 +32,8 @@
if (!(std::atoi(textInput) > 10 || std::atoi(textInput) <= 1)) {
menuOpen = false;
cubeCount = std::atoi(textInput);
currentScoreTime = GetTime();
} else {
wrongInput = true;
}