1
This commit is contained in:
@@ -58,6 +58,9 @@ namespace Game {
|
|||||||
static void destroyEntity(T* entity);
|
static void destroyEntity(T* entity);
|
||||||
static void processPendingEntityRemovals();
|
static void processPendingEntityRemovals();
|
||||||
|
|
||||||
|
static void pushPlayerPosition(Object::Transform transform) { mPlayerTransformHistory.push_back(transform); }
|
||||||
|
static void getPlayerPositionHistory(std::vector<Object::Transform>& outHistory) { outHistory = mPlayerTransformHistory; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int mTargetUpdatesPerSecond = TARGET_UPDATE_RATE;
|
int mTargetUpdatesPerSecond = TARGET_UPDATE_RATE;
|
||||||
clock::time_point mLastUpdate;
|
clock::time_point mLastUpdate;
|
||||||
@@ -65,6 +68,7 @@ namespace Game {
|
|||||||
static std::unordered_map<std::string, int> mSharedInts;
|
static std::unordered_map<std::string, int> mSharedInts;
|
||||||
static std::unordered_map<std::string, float> mSharedFloats;
|
static std::unordered_map<std::string, float> mSharedFloats;
|
||||||
static std::unordered_map<std::string, bool> mSharedBools;
|
static std::unordered_map<std::string, bool> mSharedBools;
|
||||||
|
static std::vector<Object::Transform> mPlayerTransformHistory;
|
||||||
static GameStateEnum mCurrentGameState;
|
static GameStateEnum mCurrentGameState;
|
||||||
float mLastDelta = 0.f;
|
float mLastDelta = 0.f;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -35,6 +35,23 @@ namespace {
|
|||||||
file << "Igralec: " << playerName << "\n";
|
file << "Igralec: " << playerName << "\n";
|
||||||
file << "Točke: " << score << "\n";
|
file << "Točke: " << score << "\n";
|
||||||
file << "Datum: " << std::put_time(&localTime, "%Y-%m-%d %H:%M:%S") << "\n";
|
file << "Datum: " << std::put_time(&localTime, "%Y-%m-%d %H:%M:%S") << "\n";
|
||||||
|
|
||||||
|
// Replay system
|
||||||
|
std::vector<Game::Object::Transform> playerHistory;
|
||||||
|
Game::GameManager::getPlayerPositionHistory(playerHistory);
|
||||||
|
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";
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG("Zapis končne statistike in replaya igre dokončan");
|
||||||
|
replayFile.close();
|
||||||
|
file.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -161,6 +161,9 @@ namespace Game::AGame {
|
|||||||
} else if (!mIsShipMode && mGroundTex) {
|
} else if (!mIsShipMode && mGroundTex) {
|
||||||
setTexture(mGroundTex);
|
setTexture(mGroundTex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Push replay
|
||||||
|
GameManager::pushPlayerPosition(mTransform);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::onCollisionEnter(Object::Entity* other) {
|
void Player::onCollisionEnter(Object::Entity* other) {
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ namespace Game {
|
|||||||
std::unordered_map<std::string, int> GameManager::mSharedInts;
|
std::unordered_map<std::string, int> GameManager::mSharedInts;
|
||||||
std::unordered_map<std::string, float> GameManager::mSharedFloats;
|
std::unordered_map<std::string, float> GameManager::mSharedFloats;
|
||||||
std::unordered_map<std::string, bool> GameManager::mSharedBools;
|
std::unordered_map<std::string, bool> GameManager::mSharedBools;
|
||||||
|
std::vector<Object::Transform> GameManager::mPlayerTransformHistory;
|
||||||
|
|
||||||
void GameManager::removeSharedData(const std::string& key, SharedDataType type) {
|
void GameManager::removeSharedData(const std::string& key, SharedDataType type) {
|
||||||
if (type == SharedDataType::STRING) {
|
if (type == SharedDataType::STRING) {
|
||||||
|
|||||||
Reference in New Issue
Block a user