Zähler eingebaut und versucht highscore zu fixen
Zähler eingebaut und versucht highscore zu fixen
This commit is contained in:
parent
aa5ca11829
commit
c6cdebfc84
15
.idea/workspace.xml
generated
15
.idea/workspace.xml
generated
@ -7,6 +7,7 @@
|
|||||||
<option name="/Default/RiderDebugger/RiderRestoreDecompile/RestoreDecompileSetting/@EntryValue" value="false" type="bool" />
|
<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/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/@EntryIndexedValue" value="true" type="bool" />
|
||||||
|
<option name="/Default/Housekeeping/FeatureSuggestion/FeatureSuggestionManager/DisabledSuggesters/=SwitchToGoToActionSuggester/@EntryIndexRemoved" />
|
||||||
</component>
|
</component>
|
||||||
<component name="CMakePresetLoader">{
|
<component name="CMakePresetLoader">{
|
||||||
"useNewFormat": true
|
"useNewFormat": true
|
||||||
@ -30,12 +31,11 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="db070755-9708-4a46-a9cb-e7c4dc1bfb77" name="Changes" comment="">
|
<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$/.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$/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>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@ -87,7 +87,7 @@
|
|||||||
"RunOnceActivity.west.config.association.type.startup.service": "true",
|
"RunOnceActivity.west.config.association.type.startup.service": "true",
|
||||||
"cf.first.check.clang-format": "false",
|
"cf.first.check.clang-format": "false",
|
||||||
"cidr.known.project.marker": "true",
|
"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",
|
"last_opened_file_path": "C:/Desktop/StudiumME/3.Sem/Prog3/B/MatrixPybind",
|
||||||
"node.js.detected.package.eslint": "true",
|
"node.js.detected.package.eslint": "true",
|
||||||
"node.js.detected.package.tslint": "true",
|
"node.js.detected.package.tslint": "true",
|
||||||
@ -98,11 +98,6 @@
|
|||||||
}
|
}
|
||||||
}]]></component>
|
}]]></component>
|
||||||
<component name="RunManager" selected="CMake Application.Prog3B">
|
<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">
|
<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">
|
<method v="2">
|
||||||
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
|
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
|
||||||
|
|||||||
@ -0,0 +1 @@
|
|||||||
|
11.34
|
||||||
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
ScoreManager::ScoreManager(const std::string& filename) : highscoreFile(filename)
|
ScoreManager::ScoreManager(const std::string& filename) : highscoreFile(filename)
|
||||||
{
|
{
|
||||||
|
std::cout << "test";
|
||||||
loadHighscore();
|
loadHighscore();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,8 +24,6 @@ void ScoreManager::loadHighscore() {
|
|||||||
|
|
||||||
void ScoreManager::incrementScore() {
|
void ScoreManager::incrementScore() {
|
||||||
currentScore++;
|
currentScore++;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScoreManager::resetScore() {
|
void ScoreManager::resetScore() {
|
||||||
|
|||||||
23
main.cpp
23
main.cpp
@ -3,6 +3,8 @@
|
|||||||
#include "userinterface.h"
|
#include "userinterface.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#include "ScoreManager.h"
|
#include "ScoreManager.h"
|
||||||
|
|
||||||
// -----------------------------------------------------------
|
// -----------------------------------------------------------
|
||||||
@ -30,20 +32,23 @@ int main()
|
|||||||
camera.projection = CAMERA_PERSPECTIVE;
|
camera.projection = CAMERA_PERSPECTIVE;
|
||||||
|
|
||||||
//TODO: Hier die Zeit abrufen.
|
//TODO: Hier die Zeit abrufen.
|
||||||
double currentScoreTime = 11.42;
|
double currentScoreTime = 0.0;
|
||||||
double highScoreTime = 15.41;
|
double startTime = 0.0;
|
||||||
|
double highScoreTime = 43.4;
|
||||||
|
|
||||||
//TODO: Hier die Anzahl der Züge abrufen.
|
//TODO: Hier die Anzahl der Züge abrufen.
|
||||||
int currentScoreTurns = 0;
|
int currentScoreTurns = 0;
|
||||||
int highScoreTurns = score.getHighScore();
|
int highScoreTurns = score.getHighScore();
|
||||||
|
|
||||||
if (currentScoreTime <= highScoreTime) highScoreTime = currentScoreTime;
|
//if (currentScoreTime <= highScoreTime) highScoreTime = currentScoreTime;
|
||||||
if (currentScoreTime <= highScoreTurns) highScoreTurns = currentScoreTurns;
|
//if (currentScoreTime <= highScoreTurns) highScoreTurns = currentScoreTurns;
|
||||||
|
|
||||||
int cubePairs = userInterface.getCubeCount();
|
int cubePairs = userInterface.getCubeCount();
|
||||||
if (cubePairs <= 0) {
|
if (cubePairs <= 0) {
|
||||||
userInterface.showMenu(currentScoreTime, highScoreTime, currentScoreTurns, highScoreTurns);
|
userInterface.showMenu(currentScoreTime, highScoreTime, currentScoreTurns, highScoreTurns);
|
||||||
cubePairs = userInterface.getCubeCount();
|
cubePairs = userInterface.getCubeCount();
|
||||||
|
// Startzeit speichern nach Enter
|
||||||
|
startTime = currentScoreTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Vec3> positions =createCubes(cubePairs);
|
std::vector<Vec3> positions =createCubes(cubePairs);
|
||||||
@ -143,6 +148,12 @@ int main()
|
|||||||
if (!gameWon)
|
if (!gameWon)
|
||||||
gameWon = std::all_of(cubes.begin(), cubes.end(), [](const gamecube &c){ return c.IsMatched(); });
|
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
|
// Zeichnen
|
||||||
// -----------------------------------------------------------
|
// -----------------------------------------------------------
|
||||||
@ -163,14 +174,16 @@ int main()
|
|||||||
//TODO: Neue Scores zuweisen, current genügen.
|
//TODO: Neue Scores zuweisen, current genügen.
|
||||||
//currentScoreTime = 17.3;
|
//currentScoreTime = 17.3;
|
||||||
//currentScoreTurns = 10;
|
//currentScoreTurns = 10;
|
||||||
score.saveHighScore();
|
|
||||||
if (currentScoreTime <= highScoreTime) highScoreTime = currentScoreTime;
|
if (currentScoreTime <= highScoreTime) highScoreTime = currentScoreTime;
|
||||||
if (currentScoreTurns <= highScoreTurns) highScoreTurns = currentScoreTurns;
|
if (currentScoreTurns <= highScoreTurns) highScoreTurns = currentScoreTurns;
|
||||||
|
score.saveHighScore();
|
||||||
userInterface.showScore(currentScoreTime, highScoreTime, currentScoreTurns, highScoreTurns);
|
userInterface.showScore(currentScoreTime, highScoreTime, currentScoreTurns, highScoreTurns);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
DrawText("Flip 2 cubes - find matching pairs!", 10, 10, 20, DARKGRAY);
|
DrawText("Flip 2 cubes - find matching pairs!", 10, 10, 20, DARKGRAY);
|
||||||
|
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -32,6 +32,8 @@
|
|||||||
if (!(std::atoi(textInput) > 10 || std::atoi(textInput) <= 1)) {
|
if (!(std::atoi(textInput) > 10 || std::atoi(textInput) <= 1)) {
|
||||||
menuOpen = false;
|
menuOpen = false;
|
||||||
cubeCount = std::atoi(textInput);
|
cubeCount = std::atoi(textInput);
|
||||||
|
|
||||||
|
currentScoreTime = GetTime();
|
||||||
} else {
|
} else {
|
||||||
wrongInput = true;
|
wrongInput = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user