diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 2aa1416..831d8ab 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -7,7 +7,6 @@
-
{
"useNewFormat": true
@@ -32,10 +31,8 @@
-
-
+
-
@@ -76,27 +73,27 @@
- {
+ "keyToString": {
+ "CMake Application.Prog3B.executor": "Run",
+ "RunOnceActivity.RadMigrateCodeStyle": "true",
+ "RunOnceActivity.ShowReadmeOnStart": "true",
+ "RunOnceActivity.cidr.known.project.marker": "true",
+ "RunOnceActivity.git.unshallow": "true",
+ "RunOnceActivity.readMode.enableVisualFormatting": "true",
+ "RunOnceActivity.west.config.association.type.startup.service": "true",
+ "cf.first.check.clang-format": "false",
+ "cidr.known.project.marker": "true",
+ "git-widget-placeholder": "bug__fix__branch",
+ "last_opened_file_path": "C:/Desktop/StudiumME/3.Sem/Prog3/B/MatrixPybind",
+ "node.js.detected.package.eslint": "true",
+ "node.js.detected.package.tslint": "true",
+ "node.js.selected.package.eslint": "(autodetect)",
+ "node.js.selected.package.tslint": "(autodetect)",
+ "nodejs_package_manager_path": "npm",
+ "vue.rearranger.settings.migration": "true"
}
-}]]>
+}
@@ -127,6 +124,7 @@
+
diff --git a/gamecube.h b/gamecube.h
index bbe0028..4b95d25 100644
--- a/gamecube.h
+++ b/gamecube.h
@@ -31,4 +31,12 @@ private:
bool flippingForward = false;
bool flippingBackward = false;
float rotation = 0.0f;
+};
+
+enum class GameState
+{
+ Idle, // kein Würfel offen, Eingabe erlaubt
+ OneFlipped, // ein Würfel offen
+ CheckingMatch, // zwei Würfel vollständig aufgeklappt, Vergleich läuft
+ LockInput // Würfel drehen gerade – Eingabe kurz blockiert
};
\ No newline at end of file
diff --git a/main.cpp b/main.cpp
index 6a8db51..04f7621 100644
--- a/main.cpp
+++ b/main.cpp
@@ -31,6 +31,9 @@ int main()
camera.fovy = 45.0f;
camera.projection = CAMERA_PERSPECTIVE;
+ GameState state = GameState::Idle;
+
+
//TODO: Hier die Zeit abrufen.
double currentScoreTime = 0.0;
double startTime = 0.0;
@@ -53,7 +56,7 @@ int main()
std::vector positions =createCubes(cubePairs);
- // Nur 3 Farben für 3 Paare
+ // Nur x Farben für x Paare
std::vector colors= getColors(cubePairs);
@@ -88,7 +91,11 @@ int main()
while (!WindowShouldClose())
{
// Klick-Erkennung
- if (!gameWon && IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
+ //if (!gameWon && IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
+ if (!gameWon
+ && state != GameState::LockInput
+ && state != GameState::CheckingMatch
+ && IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
{
Vector2 mouse = GetMousePosition();
@@ -100,12 +107,26 @@ int main()
if (fabs(mouse.x - screenPos.x) < 40 && fabs(mouse.y - screenPos.y) < 40)
{
+ if (state == GameState::OneFlipped && first == &c)
+ break;
+
c.FlipForward();
+
+ if (state == GameState::Idle)
+ {
+ first = &c;
+ state = GameState::OneFlipped;
+ }else if (state == GameState::OneFlipped && first != &c)
+ {
+ second = &c;
+ state = GameState::LockInput;
+ }
+
score.incrementScore();
currentScoreTurns = score.getCurrentScore() / 2;
+
+ break;
}
-
-
}
}
}
@@ -114,17 +135,19 @@ int main()
for (auto &c : cubes)
{
c.Update(flipSpeed);
+ }
- // Sobald ein Würfel vollständig umgedreht ist → merken
- if (c.IsFlipped() && !c.IsMatched())
+
+ if (state == GameState::LockInput && first && second)
+ {
+ if (first->GetRotationY() == 180.0f && second->GetRotationY() == 180.0f)
{
- if (!first) first = &c;
- else if (!second && &c != first) second = &c;
+ state = GameState::CheckingMatch;
}
}
// Matching-Logik
- if (first && second)
+ if (state == GameState::CheckingMatch && first && second)
{
//currentScoreTurns = score.getCurrentScore();
Color col1 = first->GetColor();
@@ -142,6 +165,8 @@ int main()
}
first = second = nullptr;
+ state = GameState::Idle;
+ std::cout <<"unlock";
}
// Gewinnprüfung