📄 ghostmovewhenkilledactions.cpp
字号:
// GhostMoveWhenKilledActions.cpp
//
/////////////////////////////////////////////////////////////////////////////
#include "GhostMoveWhenKilledActions.h"
#include "Ghost.h"
#include "Game.h"
void GhostGoHomeAction::run(Ghost *ghost)
{
// moves
ghost->move();
// if the ghost is in front of home, change state to entering home after being killed
if ((ghost->posX == 0x80) && (ghost->posY == 0x64)){
ghost->state = 2;
}
}
void GhostEnterHomeAndEndAction::run(Ghost *ghost)
{
// moves down
ghost->posX += movementOffsets[DOWN][0];
ghost->posY += movementOffsets[DOWN][1];
// updates orientation
ghost->prevOrientation = ghost->orientation = DOWN;
// if the ghost has fully entered home
if (ghost->posY == 0x80){
// set tile positions
ghost->tilePosX = ghost->actualTilePosX = 0x2e;
ghost->tilePosY = ghost->actualTilePosY = 0x2f;
// reset ghost state (alive, at home and not in panic mode)
ghost->state = 0;
ghost->substate = 0;
ghost->panicMode = false;
// TODOSOUND: check all ghost's states and if no more are dead, stop returning home sound
}
}
void GhostGoHomeAndContinueAction::run(Ghost *ghost)
{
// moves down
ghost->posX += movementOffsets[DOWN][0];
ghost->posY += movementOffsets[DOWN][1];
// updates orientation
ghost->prevOrientation = ghost->orientation = DOWN;
// if the ghost has fully entered home, change state
if (ghost->posY == 0x80){
ghost->state++;
}
}
void GhostMoveToLeftHomeSideAction::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 left side
if (ghost->posX == 0x90){
// set tile positions
ghost->tilePosX = ghost->actualTilePosX = 0x30;
ghost->tilePosY = ghost->actualTilePosY = 0x2f;
// reset ghost state (alive, at home and not in panic mode)
ghost->state = 0;
ghost->substate = 0;
ghost->panicMode = false;
// TODOSOUND: check all ghost's states and if no more are dead, stop returning home sound
}
}
void GhostMoveToRightHomeSideAction::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 right side
if (ghost->posX == 0x70){
// set tile positions
ghost->tilePosX = ghost->actualTilePosX = 0x2c;
ghost->tilePosY = ghost->actualTilePosY = 0x2f;
// reset ghost state (alive, at home and not in panic mode)
ghost->state = 0;
ghost->substate = 0;
ghost->panicMode = false;
// TODOSOUND: check all ghost's states and if no more are dead, stop returning home sound
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -