📄 firstcutscene.cpp
字号:
// FirstCutscene.cpp
//
/////////////////////////////////////////////////////////////////////////////
#include <cassert>
#include "CommonCutscene.h"
#include "FirstCutscene.h"
#include "Game.h"
#include "Ghost.h"
#include "Pacman.h"
#include "Video.h"
GameSubstate *FirstCutsceneState::substates[7];
/////////////////////////////////////////////////////////////////////////////
// cutscene state
/////////////////////////////////////////////////////////////////////////////
FirstCutsceneState::FirstCutsceneState()
{
substates[0x00] = new FirstCutscene0Substate();
substates[0x01] = new FirstCutscene1Substate();
substates[0x02] = new FirstCutscene2Substate();
substates[0x03] = 0;
substates[0x04] = new FirstCutscene4Substate();
substates[0x05] = new FirstCutscene5Substate();
substates[0x06] = new FirstCutscene6Substate();
}
FirstCutsceneState::~FirstCutsceneState()
{
// delete cutscene substates
for (int i = 0; i < 7; i++){
delete substates[i];
}
}
void FirstCutsceneState::run()
{
assert((theGame->cutsceneState[0] >= 0) && (theGame->cutsceneState[0] < 7));
// delegate the action to the substate
if (substates[theGame->cutsceneState[0]]){
substates[theGame->cutsceneState[0]]->run();
}
}
/////////////////////////////////////////////////////////////////////////////
// cutscene substate
/////////////////////////////////////////////////////////////////////////////
void FirstCutscene0Substate::run()
{
if (theGame->pacman->tilePosX == 0x21){
// set red ghost to go for pacman
theGame->ghost[RED]->substate = 1;
theGame->secondDiffFlag = true;
// draws an invisible mini level
Video::drawInvisibleMiniLevel();
// increment cutscene substate
theGame->cutsceneState[0]++;
} else {
cutsceneMainLoop(false);
}
}
void FirstCutscene1Substate::run()
{
if (theGame->pacman->tilePosX == 0x1e){
// increment cutscene substate
theGame->cutsceneState[0]++;
} else {
cutsceneMainLoop(false);
}
}
void FirstCutscene2Substate::run()
{
if (theGame->ghost[RED]->actualTilePosX == 0x1e){
// make the game think that pacman has eaten a super pill
theGame->initSuperPillVars();
// TODOSOUND: stop sound
// change pacman orientation
theGame->pacman->checkOrientationChanges();
theGame->pacman->movOffsX = theGame->pacman->wantedMovOffsX;
theGame->pacman->movOffsY = theGame->pacman->wantedMovOffsY;
theGame->pacman->orientation = theGame->pacman->wantedOrientation;
// schedules a cutscene substate change in 0.5 seconds
theScheduler->addScheduledTask(new Task(7, Task::TEN_HUNDREDTHS, 5));
// increment cutscene substate
theGame->cutsceneState[0]++;
} else {
// moves red ghost
theGame->ghost[RED]->run();
theGame->ghost[RED]->run();
theGame->updateGhostAnimCounters();
}
}
void FirstCutscene4Substate::run()
{
if (theGame->ghost[RED]->actualTilePosX == 0x2f){
// increment cutscene substate
theGame->cutsceneState[0]++;
} else {
// moves red ghost
theGame->ghost[RED]->run();
theGame->ghost[RED]->run();
theGame->updateGhostAnimCounters();
}
}
void FirstCutscene5Substate::run()
{
if (theGame->ghost[RED]->actualTilePosX == 0x3d){
// increment cutscene substate
theGame->cutsceneState[0]++;
} else {
cutsceneMainLoop(false);
}
}
void FirstCutscene6Substate::run()
{
// moves pacman
theGame->pacman->run();
theGame->pacman->run();
if (theGame->pacman->tilePosX == 0x3d){
// reset cutscene state
theGame->cutsceneState[0] = 0;
// schedules a substate change in 0.5 seconds
theScheduler->addScheduledTask(new Task(0, Task::TEN_HUNDREDTHS, 5));
// increments level substate
theGame->states[PLAYING]->substate++;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -