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

📄 coininsertedsubstates.cpp

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

#include "CoinInsertedSubstates.h"
#include "Game.h"
#include "../InputHandler.h"
#include "Video.h"
#include "Writer.h"

void CoinInsertedShowInfoSubstate::run()
{
	// print actual credit configuration
	Writer::printCredits();

	// clear gameplay area
	Video::clearVRAM(true);

	// init Color RAM
	Video::initCRAM(0);

	// print push start button and (c) Namco
	Writer::printString(0x07);
	Writer::printString(0x0b);

	// reset pacman, fruit and ghosts positions
	theGame->resetCharacterPositions();

	// increment substate
	theGame->states[COIN_INSERTED]->substate++;

	// print bonus/life points
	if (theGame->settings.bonusLife != MAX_INT){
		Writer::printString(0x0a);
		Writer::printBonusLifeMSB();
	}
}

void CoinInsertedWaitForStartSubstate::run()
{
	// print actual credit configuration
	Writer::printCredits();

	int credits = theGame->settings.credits;

	// print "1 player only" or "1 or 2 players"
	Writer::printString((credits == 0x01) ? 8 : 9);

	// check 1P and 2P start
	if ((credits != 0x01) && ((theInputHandler->getInput(1) & 0x40) == 0)){
		theGame->numberOfPlayers = 1;
	} else if ((theInputHandler->getInput(1) & 0x20) == 0){
		theGame->numberOfPlayers = 0;
	} else return;

	// if free play is not set, decrement credits
	if (theGame->settings.coinsPerCredit[COINS] != 0){
		theGame->settings.credits -= theGame->numberOfPlayers + 1;
	}

	// print actual credit configuration
	Writer::printCredits();

	// increment substate
	theGame->states[COIN_INSERTED]->substate++;

	// TODOSOUND: do something sound related
}

void CoinInsertedPrepareFirstLevelSubstate::run()
{
	// clear gameplay area
	Video::clearVRAM(true);

	// init CRAM with special color entries
	Video::initCRAM(1);

	// draw maze
	Video::drawGameLevel();

	// init pills
	theGame->levelState[0].initPills();

	// draw active player pills
	Video::drawPlayerPills();

	// print player one and ready
	Writer::printString(3);
	Writer::printString(6);

	// init and print scores
	Writer::initAndPrintScores();

	// draw level fruits
	Video::drawLevelFruits();

	// set initial level
	theGame->levelState[0].currentLevel = 0;

	// set number of lives
	theGame->levelState[0].lives = theGame->settings.lives;
	theGame->levelState[0].displayedLives = theGame->settings.lives;

	// draw lives
	Video::initLivesCRAM();
	Video::drawLives(theGame->levelState[0].displayedLives);

	// schedules a substate change in a 2.3 seconds
	theScheduler->addScheduledTask(new Task(1, Task::TEN_HUNDREDTHS, 23));

	// increments substate
	theGame->states[COIN_INSERTED]->substate++;
}

void CoinInsertedChangeToPlayingSubstate::run()
{
	// decrement displayed lives
	theGame->levelState[0].displayedLives--;
	Video::initLivesCRAM();
	Video::drawLives(theGame->levelState[0].displayedLives);

	// change to playing state
	theGame->states[COIN_INSERTED]->substate = 0;
	theGame->states[DEMO]->substate = 0;
	theGame->states[PLAYING]->substate = 0;
	theGame->state++;
}

⌨️ 快捷键说明

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