This commit is contained in:
Vladislav Khorev 2026-02-28 13:33:33 +03:00
commit 7e5aa22fee
10 changed files with 93 additions and 30 deletions

View File

@ -14,40 +14,78 @@
{
"type": "Button",
"name": "gameOverText",
"x": 350,
"y": 400,
"width": 600,
"height": 150,
"x": 476.5,
"y": 500,
"width": 327,
"height": 26,
"textures": {
"normal": "resources/gameover.png",
"hover": "resources/gameover.png",
"pressed": "resources/gameover.png"
"normal": "resources/game_over/MissionFailed.png",
"hover": "resources/game_over/MissionFailed.png",
"pressed": "resources/game_over/MissionFailed.png"
}
},
{
"type": "Button",
"name": "restartButton",
"x": 350,
"y": 300,
"width": 300,
"height": 80,
"name": "underlineBtn",
"x": 556,
"y": 465,
"width": 168,
"height": 44,
"textures": {
"normal": "resources/shoot_normal.png",
"hover": "resources/shoot_normal.png",
"pressed": "resources/shoot_normal.png"
"normal": "resources/game_over/Container.png",
"hover": "resources/game_over/Container.png",
"pressed": "resources/game_over/Container.png"
}
},
{
"type": "Button",
"name": "finalscore",
"x": 596.5,
"y": 436,
"width": 87,
"height": 9,
"textures": {
"normal": "resources/game_over/FinalScore.png",
"hover": "resources/game_over/FinalScore.png",
"pressed": "resources/game_over/FinalScore.png"
}
},
{
"type": "TextView",
"name": "scoreText",
"x": 350,
"y": 356,
"width": 600,
"height": 80,
"text": "0",
"fontSize": 36,
"color": [0, 217, 255, 1],
"align": "center"
},
{
"type": "Button",
"name": "restartButton",
"x": 449,
"y": 308,
"width": 382,
"height": 56,
"textures": {
"normal": "resources/game_over/Filledbuttons.png",
"hover": "resources/game_over/Filledbuttons.png",
"pressed": "resources/game_over/Filledbuttons.png"
}
},
{
"type": "Button",
"name": "gameOverExitButton",
"x": 650,
"y": 300,
"width": 300,
"height": 80,
"x": 449,
"y": 240,
"width": 382,
"height": 56,
"textures": {
"normal": "resources/sand2.png",
"hover": "resources/sand2.png",
"pressed": "resources/sand2.png"
"normal": "resources/game_over/Secondarybutton.png",
"hover": "resources/game_over/Secondarybutton.png",
"pressed": "resources/game_over/Secondarybutton.png"
}
}
]

BIN
resources/game_over/Container.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
resources/game_over/Filledbuttons.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
resources/game_over/FinalScore.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
resources/game_over/MissionFailed.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
resources/game_over/Secondarybutton.png (Stored with Git LFS) Normal file

Binary file not shown.

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;
@ -258,14 +258,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) {

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;

View File

@ -276,7 +276,7 @@ namespace ZL
std::cerr << "Client: Failed to send RESPAWN\n";
}
}
this->playerScore = 0;
std::cerr << "Game restarted\n";
};
@ -1598,7 +1598,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;
@ -1673,7 +1673,7 @@ namespace ZL
planetObject.planetStones.statuses[collidedTriIdx] = ChunkStatus::Empty;
}
menuManager.showGameOver();
menuManager.showGameOver(this->playerScore);
}
}
}
@ -1777,12 +1777,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;
}
}
}

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;