trop de trucs oscours

This commit is contained in:
2025-03-22 17:41:33 +01:00
parent d87ddcdc22
commit 30dd323e22
13 changed files with 265 additions and 162 deletions

View File

@@ -136,7 +136,6 @@ void TextApp::seeKeybinds() const {
void TextApp::defaultKeybinds() {
this->keybinds.clear();
this->keybinds.insert({"quit", QUIT});
this->keybinds.insert({"pause", PAUSE});
this->keybinds.insert({"retry", RETRY});
this->keybinds.insert({"h", HOLD});
@@ -171,15 +170,21 @@ void TextApp::startGame() const {
std::set<Action> playerActions;
std::set<Action> lastFrameActions;
std::set<Action> metaActions;
bool retrying = false;
for (std::string action : actions) {
try {
Action playerAction = this->keybinds.at(action);
if (playerAction == PAUSE || playerAction == RETRY || playerAction == quit) {
metaActions.insert(playerAction);
}
else {
if (playerAction == SOFT_DROP || playerAction == MOVE_LEFT || playerAction == MOVE_RIGHT) {
if (action == "quit") {
quit = true;
}
else {
try {
Action playerAction = this->keybinds.at(action);
if (playerAction == RETRY) {
retrying = true;
}
else if (playerAction == PAUSE) {
paused = (!paused);
}
else if (playerAction == SOFT_DROP || playerAction == MOVE_LEFT || playerAction == MOVE_RIGHT) {
playerActions.insert(playerAction);
lastFrameActions.insert(playerAction);
}
@@ -190,19 +195,12 @@ void TextApp::startGame() const {
playerActions.insert(playerAction);
}
}
catch (std::exception ignored) {}
}
catch (std::exception ignored) {}
}
if (metaActions.contains(PAUSE)) {
paused = (!paused);
}
if (!paused) {
if (metaActions.contains(QUIT)) {
quit = true;
}
else if (metaActions.contains(RETRY)) {
if (!paused && !quit) {
if (retrying) {
game.reset();
game.start();
}