"How to play" added

This commit is contained in:
2021-04-05 19:07:33 +02:00
parent 36bb6b8fe8
commit 2330820a15
4 changed files with 95 additions and 36 deletions

View File

@@ -183,7 +183,7 @@ void GameDirector::initProg()
mMenu.title->addItem("OPTIONS"); mMenu.title->addItem("OPTIONS");
mMenu.title->addItem("HOW TO PLAY", 0, 5); mMenu.title->addItem("HOW TO PLAY", 0, 5);
mMenu.title->addItem("QUIT"); mMenu.title->addItem("QUIT");
mMenu.title->setDefaultActionWhenCancel(2); mMenu.title->setDefaultActionWhenCancel(3);
mMenu.title->setBackgroundColor(0x30, 0x30, 0x40, 192); mMenu.title->setBackgroundColor(0x30, 0x30, 0x40, 192);
mMenu.title->setSelectorColor(0xe5, 0x1c, 0x23, 255); mMenu.title->setSelectorColor(0xe5, 0x1c, 0x23, 255);
mMenu.title->setSelectorTextColor(0xFF, 0xF1, 0x76); mMenu.title->setSelectorTextColor(0xFF, 0xF1, 0x76);
@@ -684,6 +684,7 @@ void GameDirector::resetTitle(Uint8 subsection)
mTitle.menuVisible = false; mTitle.menuVisible = false;
mTitle.nextProgSection = PROG_SECTION_GAME; mTitle.nextProgSection = PROG_SECTION_GAME;
mTitle.instructionsCounter = INSTRUCTIONS_COUNTER; mTitle.instructionsCounter = INSTRUCTIONS_COUNTER;
mTitle.instructionsMode = MODE_AUTO;
// Inicializa el bitmap de Coffee // Inicializa el bitmap de Coffee
mTitle.coffeeBitmap->init(mTexture[TEXTURE_TITLE].texture, mRenderer); mTitle.coffeeBitmap->init(mTexture[TEXTURE_TITLE].texture, mRenderer);
@@ -4064,7 +4065,7 @@ void GameDirector::renderFade(Uint8 index)
void GameDirector::renderMessages() void GameDirector::renderMessages()
{ {
// GetReady // GetReady
if (mGame.counter < STAGE_COUNTER) if ((mGame.counter < STAGE_COUNTER) && (!mDemo.enabled))
{ {
mGame.getReadyBitmap->setPosX((int)mGame.getReadyBitmapPath[mGame.counter]); mGame.getReadyBitmap->setPosX((int)mGame.getReadyBitmapPath[mGame.counter]);
mGame.getReadyBitmap->render(); mGame.getReadyBitmap->render();
@@ -4096,8 +4097,8 @@ void GameDirector::renderMessages()
{ {
if (mDemo.counter % 30 > 14) if (mDemo.counter % 30 > 14)
{ {
mText.black->writeCentered(PLAY_AREA_CENTER_X + 1, PLAY_AREA_FIRST_QUARTER_Y + 1, "D E M O"); mText.blackX2->writeCentered(PLAY_AREA_CENTER_X + 2, PLAY_AREA_FIRST_QUARTER_Y + 2, "D E M O");
mText.white->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, "D E M O"); mText.whiteX2->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, "D E M O");
} }
} }
@@ -4752,8 +4753,7 @@ void GameDirector::runTitle(Uint8 subsection)
mMenu.active->reset(); mMenu.active->reset();
mMenu.keyPressed = false; mMenu.keyPressed = false;
mTitle.section = TITLE_SECTION_INSTRUCTIONS; mTitle.section = TITLE_SECTION_INSTRUCTIONS;
//runInstructions(MODE_MANUAL); mTitle.instructionsMode = MODE_MANUAL;
//setProgSection(PROG_SECTION_TITLE,TITLE_SECTION_INSTRUCTIONS);
break; break;
case 3: // QUIT case 3: // QUIT
JA_PlaySound(mSound[SOUND_MENU_CANCEL].sound); JA_PlaySound(mSound[SOUND_MENU_CANCEL].sound);
@@ -4827,7 +4827,7 @@ void GameDirector::runTitle(Uint8 subsection)
// Sección Instrucciones // Sección Instrucciones
if (mTitle.section == TITLE_SECTION_INSTRUCTIONS) if (mTitle.section == TITLE_SECTION_INSTRUCTIONS)
runInstructions(MODE_AUTO); runInstructions(mTitle.instructionsMode);
} }
quitTitle(); quitTitle();
@@ -5039,6 +5039,10 @@ void GameDirector::runInstructions(Uint8 mode)
Sprite *sprite = new Sprite(); Sprite *sprite = new Sprite();
SDL_Rect srcRect = {0, 0, 16, 16}; SDL_Rect srcRect = {0, 0, 16, 16};
bool wannaExit = false;
if (mode == MODE_MANUAL)
mTitle.instructionsCounter = 0;
const SDL_Rect destRect1 = {60, 88 + (16 * 0), 16, 16}; // Disquito const SDL_Rect destRect1 = {60, 88 + (16 * 0), 16, 16}; // Disquito
const SDL_Rect destRect2 = {60, 88 + (16 * 1), 16, 16}; // Gavineixon const SDL_Rect destRect2 = {60, 88 + (16 * 1), 16, 16}; // Gavineixon
const SDL_Rect destRect3 = {60, 88 + (16 * 2), 16, 16}; // Pacmar const SDL_Rect destRect3 = {60, 88 + (16 * 2), 16, 16}; // Pacmar
@@ -5060,27 +5064,34 @@ void GameDirector::runInstructions(Uint8 mode)
} }
if ((mEventHandler->type == SDL_KEYDOWN) || (mEventHandler->type == SDL_JOYBUTTONDOWN)) if ((mEventHandler->type == SDL_KEYDOWN) || (mEventHandler->type == SDL_JOYBUTTONDOWN))
{
if (mode == MODE_AUTO)
{ {
JA_StopMusic(); JA_StopMusic();
setProgSection(PROG_SECTION_TITLE); setProgSection(PROG_SECTION_TITLE);
} }
else
wannaExit = true;
}
} }
// Pinta en la surface el texto y los sprites // Pinta en la surface el texto y los sprites
SDL_SetRenderTarget(mRenderer, mInstructionsSurface); SDL_SetRenderTarget(mRenderer, mInstructionsSurface);
SDL_SetRenderDrawColor(mRenderer, 0x27, 0x27, 0x36, 255); SDL_SetRenderDrawColor(mRenderer, 0x27, 0x27, 0x36, 255);
SDL_RenderClear(mRenderer); SDL_RenderClear(mRenderer);
mText.white->writeCentered(SCREEN_CENTER_X, 8, "OBJECTIVE", 0); mText.white->writeCenteredAndColored(SCREEN_CENTER_X, 8, "OBJECTIVE", 0, 0xFF, 0x7A, 0x00);
mText.white->writeCentered(SCREEN_CENTER_X, 24, "YOU HAVE TO POP AS MANY", 0); mText.white->writeCentered(SCREEN_CENTER_X, 24, "YOU HAVE TO POP AS MANY");
mText.white->writeCentered(SCREEN_CENTER_X, 34, "BALLOONS AS YOU CAN", 0); mText.white->writeCentered(SCREEN_CENTER_X, 34, "BALLOONS AS YOU CAN");
mText.white->writeCentered(SCREEN_CENTER_X, 48, "DIFFICULTY WILL BE INCREASED", 0); mText.white->writeCentered(SCREEN_CENTER_X, 48, "DIFFICULTY WILL BE INCREASED");
mText.white->writeCentered(SCREEN_CENTER_X, 58, "AS YOU SCORE POINTS", 0); mText.white->writeCentered(SCREEN_CENTER_X, 58, "AS YOU SCORE POINTS");
mText.white->writeCentered(SCREEN_CENTER_X, 75, "ITEMS", 0); mText.white->writeCenteredAndColored(SCREEN_CENTER_X, 75, "ITEMS", 0, 0xFF, 0x7A, 0x00);
mText.white->write(84, 92, "1.000 POINTS", 0); mText.white->write(84, 92, "1.000 POINTS", 0);
mText.white->write(84, 108, "2.500 POINTS", 0); mText.white->write(84, 108, "2.500 POINTS", 0);
mText.white->write(84, 124, "5.000 POINTS", 0); mText.white->write(84, 124, "5.000 POINTS", 0);
mText.white->write(84, 140, "TIME STOPPER", 0); mText.white->write(84, 140, "TIME STOPPER", 0);
mText.white->write(84, 156, "EXTRA HIT", 0); mText.white->write(84, 156, "EXTRA HIT", 0);
if ((mode == MODE_MANUAL) && (mTitle.instructionsCounter % 50 > 14))
mText.white->writeCenteredAndColored(SCREEN_CENTER_X, SCREEN_HEIGHT - 12, "PRESS ANY KEY TO RETURN", 0, 0xFF, 0x7A, 0x00);
// Disquito // Disquito
sprite->init(destRect1, mTexture[TEXTURE_ITEMS].texture, mRenderer); sprite->init(destRect1, mTexture[TEXTURE_ITEMS].texture, mRenderer);
@@ -5125,15 +5136,38 @@ void GameDirector::runInstructions(Uint8 mode)
SDL_RenderClear(mRenderer); SDL_RenderClear(mRenderer);
// Dibuja los objetos // Dibuja los objetos
if (mode == MODE_AUTO)
window.y = std::max(0, SCREEN_HEIGHT - (INSTRUCTIONS_COUNTER - mTitle.instructionsCounter) + 100); window.y = std::max(0, SCREEN_HEIGHT - (INSTRUCTIONS_COUNTER - mTitle.instructionsCounter) + 100);
else
window.y = 0;
SDL_RenderCopy(mRenderer, mInstructionsSurface, NULL, &window); SDL_RenderCopy(mRenderer, mInstructionsSurface, NULL, &window);
// Muestra la pantalla // Muestra la pantalla
SDL_RenderPresent(mRenderer); SDL_RenderPresent(mRenderer);
// Lógica
if (SDL_GetTicks() - mProg.ticks > mProg.ticksSpeed)
{
// Actualiza el contador de ticks
mProg.ticks = SDL_GetTicks();
// Modo automático
if (mode == MODE_AUTO)
{
mTitle.instructionsCounter--; mTitle.instructionsCounter--;
if (mTitle.instructionsCounter == 0) if (mTitle.instructionsCounter == 0)
{
resetTitle(TITLE_SECTION_1);
mTitle.nextProgSection = PROG_SECTION_LOGO;
}
}
// Modo manual
else
{
++mTitle.instructionsCounter %= 60000;
if (wannaExit)
{ {
resetTitle(TITLE_SECTION_1); resetTitle(TITLE_SECTION_1);
mTitle.section = TITLE_SECTION_3; mTitle.section = TITLE_SECTION_3;
@@ -5148,6 +5182,8 @@ void GameDirector::runInstructions(Uint8 mode)
mMenu.title->setSelectorPos(2); mMenu.title->setSelectorPos(2);
} }
} }
}
}
delete sprite; delete sprite;
} }

View File

@@ -169,6 +169,7 @@ private:
Uint8 nextProgSection; // Indica cual es la siguiente sección a cargar cuando termine el contador del titulo Uint8 nextProgSection; // Indica cual es la siguiente sección a cargar cuando termine el contador del titulo
Uint8 events[TITLE_TOTAL_EVENTS]; // Vector para coordinar los eventos de la pantalla de titulo Uint8 events[TITLE_TOTAL_EVENTS]; // Vector para coordinar los eventos de la pantalla de titulo
Uint16 instructionsCounter; // Contador para las instrucciones Uint16 instructionsCounter; // Contador para las instrucciones
Uint8 instructionsMode; // Modo en el que se van a mostrar las instrucciones
SmartSprite *coffeeBitmap; // Sprite con la palabra COFFEE para la pantalla de titulo SmartSprite *coffeeBitmap; // Sprite con la palabra COFFEE para la pantalla de titulo
SmartSprite *crisisBitmap; // Sprite con la palabra CRISIS para la pantalla de titulo SmartSprite *crisisBitmap; // Sprite con la palabra CRISIS para la pantalla de titulo
AnimatedSprite *dustBitmapL; // Sprite con la el polvo que aparece al colisionar el texto de la pantalla de titulo AnimatedSprite *dustBitmapL; // Sprite con la el polvo que aparece al colisionar el texto de la pantalla de titulo

View File

@@ -216,6 +216,25 @@ void Text::writeCentered(int x, int y, std::string text, int kerning)
} }
} }
// Escribe el texto centrado en un punto x y con kerning
void Text::writeCenteredAndColored(int x, int y, std::string text, int kerning, Uint8 R, Uint8 G, Uint8 B)
{
mSprite->getTexture()->setColor(R, G, B);
x = x - (Text::lenght(text, kerning) / 2);
Uint16 shift = 0;
for (Uint8 i = 0; i < text.length(); ++i)
{
mSprite->setSpriteClip(mOffset[int(text[i])].x, mOffset[int(text[i])].y, mSprite->getWidth(), mSprite->getHeight());
mSprite->setPosX(x + shift);
mSprite->setPosY(y);
mSprite->render();
shift += (mOffset[int(text[i])].w + kerning);
}
mSprite->getTexture()->setColor(255, 255, 255);
}
// Obtiene la longitud en pixels de una cadena // Obtiene la longitud en pixels de una cadena
Uint16 Text::lenght(std::string text, int kerning) Uint16 Text::lenght(std::string text, int kerning)
{ {

View File

@@ -45,6 +45,9 @@ public:
// Escribe el texto centrado en un punto x y con kerning // Escribe el texto centrado en un punto x y con kerning
void writeCentered(int x, int y, std::string text, int kerning = 0); void writeCentered(int x, int y, std::string text, int kerning = 0);
// Escribe el texto centrado en un punto x y con kerning
void writeCenteredAndColored(int x, int y, std::string text, int kerning = 0, Uint8 R = 255, Uint8 G = 255, Uint8 B = 255);
// Obtiene la longitud en pixels de una cadena // Obtiene la longitud en pixels de una cadena
Uint16 lenght(std::string text, int kerning); Uint16 lenght(std::string text, int kerning);