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

📄 pacmandeadsubstates.cpp

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

#include "PacmanDeadSubstates.h"
#include "Ghost.h"
#include "Pacman.h"
#include "Game.h"
#include "GameState.h"

void PacmanAliveSubstate::run()
{
	// nop
}

void PacmanWaitABitSubstate::run()
{
	// increment animation counter
	theGame->pacman->deadAnimCnt++;

	// after a bit, set state 5
	if (theGame->pacman->deadAnimCnt == 0x78){
		theGame->pacman->deadAnimState = 5;
	}
}

void waitToIncrementState(int anim, int limit)
{
	// set pacman sprite number
	theGame->pacman->sprite = anim;

	// increment animation counter
	theGame->pacman->deadAnimCnt++;

	// after a bit, set next state
	if (theGame->pacman->deadAnimCnt == limit){
		theGame->pacman->deadAnimState++;
	}
}

void PacmanDead0Substate::run()
{
	// reset ghost positions
	for (int i = 0; i < 4; i++){
		theGame->ghost[i]->posX = theGame->ghost[i]->posY = 0;
	}

	// set new pacman sprite and change state after a bit
	waitToIncrementState(0x34, 0xb4);
}

void PacmanDead1Substate::run()
{
	// TODOSOUND: play killed sound in channel 2

	// set new pacman sprite and change state after a bit
	waitToIncrementState(0x35, 0xc3);
}

void PacmanDead2Substate::run()
{
	// set new pacman sprite and change state after a bit
	waitToIncrementState(0x36, 0xd2);
}

void PacmanDead3Substate::run()
{
	// set new pacman sprite and change state after a bit
	waitToIncrementState(0x37, 0xe1);
}


void PacmanDead4Substate::run()
{
	// set new pacman sprite and change state after a bit
	waitToIncrementState(0x38, 0xf0);
}


void PacmanDead5Substate::run()
{
	// set new pacman sprite and change state after a bit
	waitToIncrementState(0x39, 0xff);
}

void PacmanDead6Substate::run()
{
	// set new pacman sprite and change state after a bit
	waitToIncrementState(0x3a, 0x10e);
}


void PacmanDead7Substate::run()
{
	// set new pacman sprite and change state after a bit
	waitToIncrementState(0x3b, 0x11d);
}


void PacmanDead8Substate::run()
{
	// set new pacman sprite and change state after a bit
	waitToIncrementState(0x3c, 0x12c);
}

void PacmanDead9Substate::run()
{
	// set new pacman sprite and change state after a bit
	waitToIncrementState(0x3d, 0x13b);
}


void PacmanDead10Substate::run()
{
	// TODOSOUND: stop ending dead sound

	// set new pacman sprite and change state after a bit
	waitToIncrementState(0x3e, 0x159);
}


void PacmanDead11Substate::run()
{
	// set new pacman sprite
	theGame->pacman->sprite = 0x3f;

	// increment animation counter
	theGame->pacman->deadAnimCnt++;

	// wait a bit
	if (theGame->pacman->deadAnimCnt != 0x1b8) return;
	
	// decrement number of lives displayed
	theGame->levelState[0].lives--;
	theGame->levelState[0].displayedLives--;

	// reset ghost positions
	for (int i = 0; i < 4; i++){
		theGame->ghost[i]->posX = theGame->ghost[i]->posY = 0;
		theGame->fruitPosition = 0;
	}

	// change game substate
	theGame->states[PLAYING]->substate++;
}

⌨️ 快捷键说明

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