fix game over

This commit is contained in:
Vlad committed 2026-02-28 12:07:40 +06:00
1 parent 7418bbbe27
commit c20e82634a
10 files changed
+94 -31

No files matched your search

+7 -4
View File
@@ -38,7 +38,7 @@ namespace ZL {
uiManager.startAnimationOnNode("backgroundNode", "bgScroll");
static bool isExitButtonAnimating = false;
uiManager.setAnimationCallback("settingsButton", "buttonsExit", [this]() {
std::cerr << "Settings button animation finished -> переход в настройки" << std::endl;
std::cerr << "Settings button animation finished -> ??????? ? ?????????" << std::endl;
if (uiManager.pushMenuFromSavedRoot(settingsSavedRoot)) {
uiManager.setButtonCallback("Opt1", [this](const std::string& n) {
std::cerr << "Opt1 pressed: " << n << std::endl;
@@ -184,7 +184,7 @@ namespace ZL {
});
uiManager.setButtonCallback("multiplayerButton2", [this](const std::string& name) {
std::cerr << "Multiplayer button pressed → opening multiplayer menu\n";
std::cerr << "Multiplayer button pressed ? opening multiplayer menu\n";
uiManager.startAnimationOnNode("playButton", "buttonsExit");
uiManager.startAnimationOnNode("settingsButton", "buttonsExit");
@@ -227,14 +227,17 @@ namespace ZL {
});
}
void MenuManager::showGameOver()
void MenuManager::showGameOver(int score)
{
if (!uiGameOverShown) {
if (uiManager.pushMenuFromSavedRoot(gameOverSavedRoot)) {
uiManager.setText("scoreText", std::string("Score: ") + std::to_string(score));
uiManager.setButtonCallback("restartButton", [this](const std::string& name) {
uiManager.setText("scoreText", "");
uiGameOverShown = false;
uiManager.popMenu();
onRestartPressed();
if (onRestartPressed) onRestartPressed();
});
uiManager.setButtonCallback("gameOverExitButton", [this](const std::string& name) {
+2 -1
View File
@@ -28,7 +28,8 @@ namespace ZL {
void setupMenu();
void showGameOver();
//void showGameOver();
void showGameOver(int score);
std::function<void()> onRestartPressed;
std::function<void(float)> onVelocityChanged;
+9 -4
View File
@@ -276,7 +276,7 @@ namespace ZL
std::cerr << "Client: Failed to send RESPAWN\n";
}
}
this->playerScore = 0;
std::cerr << "Game restarted\n";
};
@@ -1606,7 +1606,7 @@ namespace ZL
std::cerr << "GAME OVER: collision with planet (moved back and exploded)\n";
menuManager.showGameOver();
menuManager.showGameOver(this->playerScore);
}
else {
bool stoneCollided = false;
@@ -1681,7 +1681,7 @@ namespace ZL
planetObject.planetStones.statuses[collidedTriIdx] = ChunkStatus::Empty;
}
menuManager.showGameOver();
menuManager.showGameOver(this->playerScore);
}
}
}
@@ -1785,12 +1785,17 @@ namespace ZL
shipAlive = false;
gameOver = true;
Environment::shipState.velocity = 0.0f;
menuManager.showGameOver();
menuManager.showGameOver(this->playerScore);
}
else {
deadRemotePlayers.insert(d.targetId);
std::cout << "Marked remote player " << d.targetId << " as dead" << std::endl;
}
if (d.killerId == localId) {
this->playerScore += 1;
std::cout << "Client: Increased local score to " << this->playerScore << std::endl;
}
}
}
+1
View File
@@ -122,6 +122,7 @@ namespace ZL {
static constexpr float CLOSE_DIST = 600.0f;
std::unordered_set<int> deadRemotePlayers;
int playerScore = 0;
static constexpr float TARGET_MAX_DIST = 50000.0f;
static constexpr float TARGET_MAX_DIST_SQ = TARGET_MAX_DIST * TARGET_MAX_DIST;