/
trilirium
/
Pacman
Обзор
Документация
Войти
/
trilirium
/
Pacman
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
CoinInsertedSubstates.cpp
129 строк
3 KB
Trilirium
first commit
19 июн 2026, 11:07
19 июн 2026, 11:07
d44591e
Код
Авторство
О чём код?
// CoinInsertedSubstates.cpp // ///////////////////////////////////////////////////////////////////////////// #include "CoinInsertedSubstates.h" #include "Game.h" #include "../InputHandler.h" #include "Video.h" #include "Writer.h" using namespace Puckman; 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++; }