/
trilirium
/
Pacman
Обзор
Документация
Войти
/
trilirium
/
Pacman
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
GhostMoveAtHomeActions.cpp
86 строк
2 KB
Trilirium
first commit
19 июн 2026, 11:07
19 июн 2026, 11:07
d44591e
Код
Авторство
О чём код?
// GhostMoveAtHomeActions.cpp // ///////////////////////////////////////////////////////////////////////////// #include "GhostMoveAtHomeActions.h" #include "Ghost.h" #include "Game.h" using namespace Puckman; void GhostExitHomeAction::run(Ghost *ghost) { // if the ghost is at home and it's not set to go for pacman yet if (ghost->substate != 1) { // moves up ghost->posX += movementOffsets[UP][0]; ghost->posY += movementOffsets[UP][1]; // updates orientation ghost->prevOrientation = ghost->orientation = UP; // if it's out if (ghost->posY == 0x64){ // set tile positions ghost->tilePosX = 0x2e; ghost->tilePosY = 0x2c; // set last movement offsets to left ghost->prevMovOffsX = ghost->movOffsX = movementOffsets[LEFT][0]; ghost->prevMovOffsY = ghost->movOffsY = movementOffsets[LEFT][1]; // updates orientation ghost->prevOrientation = ghost->orientation = LEFT; // changes substate to go for pacman ghost->substate = 1; } } } void GhostMoveUpAndDownAction::run(Ghost *ghost) { // if the ghost is at home and it's not set to go for pacman yet if (ghost->substate != 1) { // if it has reached the top or the bottom, change it's orientation if ((ghost->posY == 0x78) || (ghost->posY == 0x80)){ ghost->changeOrientation(); } ghost->prevOrientation = ghost->orientation; // moves ghost->posX += ghost->movOffsX; ghost->posY += ghost->movOffsY; } } void GhostMoveFromLeftToCenterAction::run(Ghost *ghost) { // moves right ghost->posX += movementOffsets[RIGHT][0]; ghost->posY += movementOffsets[RIGHT][1]; // updates orientation ghost->prevOrientation = ghost->orientation = RIGHT; // if the ghost has fully reached the center, change substate if (ghost->posX == 0x80){ ghost->substate = 2; } } void GhostMoveFromRightToCenterAction::run(Ghost *ghost) { // moves left ghost->posX += movementOffsets[LEFT][0]; ghost->posY += movementOffsets[LEFT][1]; // updates orientation ghost->prevOrientation = ghost->orientation = LEFT; // if the ghost has fully reached the center, change substate if (ghost->posX == 0x80){ ghost->substate = 2; } }