⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 thirdcutscene.cpp

📁 VIGASOCO (VIdeo GAmes SOurce COde) Windows port (v0.01)
💻 CPP
字号:
// ThirdCutscene.cpp
//
/////////////////////////////////////////////////////////////////////////////

#include <cassert>
#include "CommonCutscene.h"
#include "ThirdCutscene.h"
#include "Game.h"
#include "RedGhost.h"
#include "Pacman.h"
#include "Video.h"

GameSubstate *ThirdCutsceneState::substates[6];

/////////////////////////////////////////////////////////////////////////////
// cutscene state
/////////////////////////////////////////////////////////////////////////////

ThirdCutsceneState::ThirdCutsceneState()
{
	substates[0x00] = new ThirdCutscene0Substate();
	substates[0x01] = new ThirdCutscene1Substate();
	substates[0x02] = 0;
	substates[0x03] = new ThirdCutscene3Substate();
	substates[0x04] = new ThirdCutscene4Substate();
	substates[0x05] = new ThirdCutscene5Substate();
}

ThirdCutsceneState::~ThirdCutsceneState()
{
	// delete cutscene substates
	for (int i = 0; i < 6; i++){
		delete substates[i];
	}
}

void ThirdCutsceneState::run()
{
	assert((theGame->cutsceneState[2] >= 0) && (theGame->cutsceneState[2] < 6));

	// delegate the action to the substate
	if (substates[theGame->cutsceneState[2]]){
		substates[theGame->cutsceneState[2]]->run();
	}
}

/////////////////////////////////////////////////////////////////////////////
// cutscene substate
/////////////////////////////////////////////////////////////////////////////

void ThirdCutscene0Substate::run()
{
	if (theGame->pacman->tilePosX == 0x25){
		// 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[2]++;
	} else {
		cutsceneMainLoop(false);
	}
}

void ThirdCutscene1Substate::run()
{
	RedGhost *rg = (RedGhost *)theGame->ghost[RED];

	if ((rg->posX == 0xfe) || (rg->posX == 0xff)){
		rg->posX += 2;

		rg->hasToChangeOrientation = true;
		rg->checkOrientationChanges();

		// schedules a cutscene substate change in a second
		theScheduler->addScheduledTask(new Task(9, Task::TEN_HUNDREDTHS, 10));

		// increment cutscene substate
		theGame->cutsceneState[2]++;
	} else {
		cutsceneMainLoop(false);

		// hide pacman if it has reached the left side
		if (theGame->pacman->tilePosX == 0x3d){
			theGame->pacman->color = 0;
		}
	}
}

void ThirdCutscene3Substate::run()
{
	if (theGame->ghost[RED]->actualTilePosX == 0x2d){
		// increment cutscene substate
		theGame->cutsceneState[2]++;
	} else {
		cutsceneMainLoop(false);
	}
}

void ThirdCutscene4Substate::run()
{
	if (theGame->ghost[RED]->actualTilePosX == 0x1e){
		// increment cutscene substate
		theGame->cutsceneState[2]++;
	} else {
		cutsceneMainLoop(false);
	}
}

void ThirdCutscene5Substate::run()
{
	// reset cutscene state
	theGame->cutsceneState[2] = 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 + -