/
trilirium
/
Pacman
Обзор
Документация
Войти
/
trilirium
/
Pacman
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
PlayerLevelState.cpp
109 строк
3 KB
Trilirium
first commit
19 июн 2026, 11:07
19 июн 2026, 11:07
d44591e
Код
Авторство
О чём код?
// PlayerLevelState.cpp // ///////////////////////////////////////////////////////////////////////////// #include <algorithm> #include "PlayerLevelState.h" using namespace Puckman; ///////////////////////////////////////////////////////////////////////////// // initialization and cleanup ///////////////////////////////////////////////////////////////////////////// PlayerLevelState::PlayerLevelState() { resetState(); } PlayerLevelState::~PlayerLevelState() { } void PlayerLevelState::resetState() { diffEntry = 0; firstFruit = secondFruit = false; eatenPills = 0; pinkGhostHomeCounter = blueGhostHomeCounter = orangeGhostHomeCounter = 0; easierFlag = false; currentLevel = 0; lives = 0; displayedLives = 0; for (int i = 0; i < 240; i++){ normalPills[i] = false; } superPills[0] = superPills[1] = superPills[2] = superPills[3] = 0; } ///////////////////////////////////////////////////////////////////////////// // player and level state management ///////////////////////////////////////////////////////////////////////////// void PlayerLevelState::initPills() { // init pills for (int i = 0; i < 240; i++){ normalPills[i] = true; } // init super pills superPills[0] = superPills[1] = superPills[2] = superPills[3] = 0x14; } void PlayerLevelState::clone(PlayerLevelState *p) { // copy player state diffEntry = p->diffEntry; firstFruit = p->firstFruit; secondFruit = p->secondFruit; eatenPills = p->eatenPills; pinkGhostHomeCounter = p->pinkGhostHomeCounter; blueGhostHomeCounter = p->blueGhostHomeCounter; orangeGhostHomeCounter = p->orangeGhostHomeCounter; easierFlag = p->easierFlag; currentLevel = p->currentLevel; lives = p->lives; displayedLives = p->displayedLives; // copy player pills for (int i = 0; i < 240; i++){ normalPills[i] = p->normalPills[i]; } // copy player super pills for (int i = 0; i < 4; i++){ superPills[i] = p->superPills[i]; } } void PlayerLevelState::swapState(PlayerLevelState *p) { // swap player state std::swap<int>(diffEntry, p->diffEntry); std::swap<bool>(firstFruit, p->firstFruit); std::swap<bool>(secondFruit, p->secondFruit); std::swap<int>(eatenPills, p->eatenPills); std::swap<int>(pinkGhostHomeCounter, p->pinkGhostHomeCounter); std::swap<int>(blueGhostHomeCounter, p->blueGhostHomeCounter); std::swap<int>(orangeGhostHomeCounter, p->orangeGhostHomeCounter); std::swap<bool>(easierFlag, p->easierFlag); std::swap<int>(currentLevel, p->currentLevel); std::swap<int>(lives, p->lives); std::swap<int>(displayedLives, p->displayedLives); // swap player pills for (int i = 0; i < 240; i++){ std::swap<bool>(normalPills[i], p->normalPills[i]); } // swap player super pills for (int i = 0; i < 4; i++){ std::swap<int>(superPills[i], p->superPills[i]); } }