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

📄 secondcutscene.cpp

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

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

GameSubstate *SecondCutsceneState::substates[0x0e];

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

SecondCutsceneState::SecondCutsceneState()
{
	substates[0x00] = new SecondCutscene0Substate();
	substates[0x01] = 0;
	substates[0x02] = new SecondCutscene2Substate();
	substates[0x03] = new SecondCutscene3Substate();
	substates[0x04] = new SecondCutscene4Substate();
	substates[0x05] = new SecondCutscene5Substate();
	substates[0x06] = new SecondCutscene6Substate();
	substates[0x07] = new SecondCutscene7Substate();
	substates[0x08] = 0;
	substates[0x09] = new SecondCutscene9Substate();
	substates[0x0a] = 0;
	substates[0x0b] = new SecondCutsceneBSubstate();
	substates[0x0c] = 0;
	substates[0x0d] = new SecondCutsceneDSubstate();
}

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

void SecondCutsceneState::run()
{
	assert((theGame->cutsceneState[1] >= 0) && (theGame->cutsceneState[1] < 0x0e));

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

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

void SecondCutscene0Substate::run()
{
	// prepares Color RAM square near the center
	theGame->CRAM[0x01d2] = theGame->CRAM[0x01d3] = 1;
	theGame->CRAM[0x01f2] = theGame->CRAM[0x01f3] = 1;

	// draws an invisible mini level
	Video::drawInvisibleMiniLevel();

	// sets an obstacle where red ghost will collide
	theGame->VRAM[0x1d2] = 0x60;
	theGame->VRAM[0x1d3] = 0x61;

	// schedules a cutscene substate change in 0.3 seconds
	theScheduler->addScheduledTask(new Task(8, Task::TEN_HUNDREDTHS, 3));

	// increment cutscene substate
	theGame->cutsceneState[1]++;
}

void SecondCutscene2Substate::run()
{
	if (theGame->pacman->tilePosX == 0x2c){
		// set red ghost to go for pacman
		theGame->ghost[RED]->substate = 1;
		theGame->secondDiffFlag = true;

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

void SecondCutscene3Substate::run()
{
	RedGhost *rg = (RedGhost *)theGame->ghost[RED];
	if ((rg->posX == 0x77) || (rg->posX == 0x78)){
		rg->movDiffFlag2Pattern = 0x20842084;
		
		// increment cutscene substate
		theGame->cutsceneState[1]++;
	} else {
		cutsceneMainLoop(false);
	}
}

void SecondCutscene4Substate::run()
{
	if (theGame->ghost[RED]->posX == 0x78){
		// change obstacle tiles (red ghost is hooked)
		theGame->VRAM[0x1d2] = 0x62;
		theGame->VRAM[0x1d3] = 0x63;

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

void SecondCutscene5Substate::run()
{
	if (theGame->ghost[RED]->posX == 0x7b){
		// change obstacle tiles (red ghost is more hooked)
		theGame->VRAM[0x1d2] = 0x64;
		theGame->VRAM[0x1d3] = 0x65;
		theGame->VRAM[0x1f2] = 0x66;
		theGame->VRAM[0x1f3] = 0x67;

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

void SecondCutscene6Substate::run()
{
	if (theGame->ghost[RED]->posX == 0x7e){
		// change obstacle tiles (red ghost is even more hooked)
		theGame->VRAM[0x1d2] = 0x68;
		theGame->VRAM[0x1d3] = 0x69;
		theGame->VRAM[0x1f2] = 0x6a;
		theGame->VRAM[0x1f3] = 0x6b;

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

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

void SecondCutscene7Substate::run()
{
	if (theGame->ghost[RED]->posX == 0x80){
		// schedules a cutscene substate change in 1.5 seconds
		theScheduler->addScheduledTask(new Task(8, Task::TEN_HUNDREDTHS, 15));

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

void SecondCutscene9Substate::run()
{
	theGame->ghost[RED]->posX += 2;

	// set broken ghost tiles
	theGame->VRAM[0x1d2] = 0x6c;
	theGame->VRAM[0x1d3] = 0x6d;
	theGame->VRAM[0x1f2] = theGame->VRAM[0x1f3] = 0x40;

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

	// increment cutscene substate
	theGame->cutsceneState[1]++;
}

void SecondCutsceneBSubstate::run()
{
	// schedules a cutscene substate change in 2 seconds
	theScheduler->addScheduledTask(new Task(8, Task::TEN_HUNDREDTHS, 20));

	// increment cutscene substate
	theGame->cutsceneState[1]++;
}

void SecondCutsceneDSubstate::run()
{
	// reset cutscene state
	theGame->cutsceneState[1] = 0;

	// increments level substate
	theGame->states[PLAYING]->substate += 2;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -