This commit is contained in:
2026-05-19 22:35:10 +02:00
parent d93e71e716
commit 0b45643ef2
21 changed files with 806 additions and 235 deletions

View File

@@ -36,17 +36,23 @@ namespace {
file << "Točke: " << score << "\n";
file << "Datum: " << std::put_time(&localTime, "%Y-%m-%d %H:%M:%S") << "\n";
// Replay system
// Replay system with form state
std::vector<Game::Object::Transform> playerHistory;
std::vector<bool> formHistory;
Game::GameManager::getPlayerPositionHistory(playerHistory);
Game::GameManager::getPlayerFormHistory(formHistory);
std::ofstream replayFile("replay.txt", std::ios::trunc);
if (!replayFile.is_open()) {
WARN("Neuspešno odpiranje replay.txt za pisanje");
return;
}
for (const auto& transform : playerHistory) {
replayFile << transform.x << " " << transform.y << " " << transform.rotation << " " << transform.scaleX << " " << transform.scaleY << "\n";
for (size_t i = 0; i < playerHistory.size(); ++i) {
const auto& transform = playerHistory[i];
bool isShipMode = (i < formHistory.size()) ? formHistory[i] : true;
int shipFlag = isShipMode ? 1 : 0;
replayFile << transform.x << " " << transform.y << " " << transform.rotation << " " << transform.scaleX << " " << transform.scaleY << " " << shipFlag << "\n";
}
LOG("Zapis končne statistike in replaya igre dokončan");

View File

@@ -33,13 +33,19 @@ namespace Game::AGame {
};
if (GameManager::getSharedData<bool>("gameLost")) {
setText("Umrl si!");
if (getText() != "Umrl si!") {
const std::string s = "Umrl si!";
Window::Window::postToMainThread([this, s]() { setText(s); });
}
anchorTopRight();
return;
}
if (GameManager::getSharedData<bool>("gameWon")) {
setText("Zmagal si!");
if (getText() != "Zmagal si!") {
const std::string s = "Zmagal si!";
Window::Window::postToMainThread([this, s]() { setText(s); });
}
anchorTopRight();
return;
}
@@ -53,7 +59,10 @@ namespace Game::AGame {
<< " | Smeti " << GameManager::getSharedData<int>("trashActiveCount")
<< " | Sovražniki " << GameManager::getSharedData<int>("enemyActiveCount");
setText(stream.str());
const std::string newHudText = stream.str();
if (getText() != newHudText) {
Window::Window::postToMainThread([this, newHudText]() { setText(newHudText); });
}
anchorTopRight();
}
}

View File

@@ -162,8 +162,9 @@ namespace Game::AGame {
setTexture(mGroundTex);
}
// Push replay
// Push replay (position and form state)
GameManager::pushPlayerPosition(mTransform);
GameManager::pushPlayerFormState(mIsShipMode);
}
void Player::onCollisionEnter(Object::Entity* other) {