"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
@@ -5061,8 +5065,13 @@ void GameDirector::runInstructions(Uint8 mode)
if ((mEventHandler->type == SDL_KEYDOWN) || (mEventHandler->type == SDL_JOYBUTTONDOWN)) if ((mEventHandler->type == SDL_KEYDOWN) || (mEventHandler->type == SDL_JOYBUTTONDOWN))
{ {
JA_StopMusic(); if (mode == MODE_AUTO)
setProgSection(PROG_SECTION_TITLE); {
JA_StopMusic();
setProgSection(PROG_SECTION_TITLE);
}
else
wannaExit = true;
} }
} }
@@ -5070,17 +5079,19 @@ void GameDirector::runInstructions(Uint8 mode)
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,27 +5136,52 @@ void GameDirector::runInstructions(Uint8 mode)
SDL_RenderClear(mRenderer); SDL_RenderClear(mRenderer);
// Dibuja los objetos // Dibuja los objetos
window.y = std::max(0, SCREEN_HEIGHT - (INSTRUCTIONS_COUNTER - mTitle.instructionsCounter) + 100); if (mode == MODE_AUTO)
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);
mTitle.instructionsCounter--; // Lógica
if (SDL_GetTicks() - mProg.ticks > mProg.ticksSpeed)
if (mTitle.instructionsCounter == 0)
{ {
resetTitle(TITLE_SECTION_1); // Actualiza el contador de ticks
mTitle.section = TITLE_SECTION_3; mProg.ticks = SDL_GetTicks();
mTitle.nextProgSection = PROG_SECTION_LOGO;
// Prepara las variables para la sección 3 del titulo // Modo automático
mTitle.dustBitmapL->setEnabled(false); if (mode == MODE_AUTO)
mTitle.dustBitmapR->setEnabled(false); {
mTitle.menuVisible = true; mTitle.instructionsCounter--;
mTitle.coffeeBitmap->setPosY(11);
mTitle.crisisBitmap->setPosY(57); if (mTitle.instructionsCounter == 0)
mMenu.title->setSelectorPos(2); {
resetTitle(TITLE_SECTION_1);
mTitle.nextProgSection = PROG_SECTION_LOGO;
}
}
// Modo manual
else
{
++mTitle.instructionsCounter %= 60000;
if (wannaExit)
{
resetTitle(TITLE_SECTION_1);
mTitle.section = TITLE_SECTION_3;
mTitle.nextProgSection = PROG_SECTION_LOGO;
// Prepara las variables para la sección 3 del titulo
mTitle.dustBitmapL->setEnabled(false);
mTitle.dustBitmapR->setEnabled(false);
mTitle.menuVisible = true;
mTitle.coffeeBitmap->setPosY(11);
mTitle.crisisBitmap->setPosY(57);
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

@@ -7,8 +7,8 @@
// Clase texto. Pinta texto en pantalla a partir de un bitmap // Clase texto. Pinta texto en pantalla a partir de un bitmap
class Text class Text
{ {
private: private:
Sprite *mSprite;// Objeto con los graficos para el texto Sprite *mSprite; // Objeto con los graficos para el texto
struct Offset struct Offset
{ {
@@ -16,10 +16,10 @@ class Text
int y; int y;
Uint8 w; Uint8 w;
}; };
Offset mOffset[255];// Vector con las posiciones y ancho de cada letra Offset mOffset[255]; // Vector con las posiciones y ancho de cada letra
Uint8 mType;// Indica si el texto es de anchura fija o variable Uint8 mType; // Indica si el texto es de anchura fija o variable
Uint8 mSize;// Altura del texto Uint8 mSize; // Altura del texto
public: public:
// Constructor // Constructor
@@ -39,12 +39,15 @@ public:
// Escribe el texto con colores // Escribe el texto con colores
void writeColored(int x, int y, std::string text, Uint8 R, Uint8 G, Uint8 B); void writeColored(int x, int y, std::string text, Uint8 R, Uint8 G, Uint8 B);
// Escribe el texto con sombra // Escribe el texto con sombra
void writeShadowed(int x, int y, std::string text, Uint8 R, Uint8 G, Uint8 B); void writeShadowed(int x, int y, std::string text, Uint8 R, Uint8 G, Uint8 B);
// 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);
@@ -53,7 +56,7 @@ public:
// Establece el valor de la variable // Establece el valor de la variable
void setType(Uint8 type); void setType(Uint8 type);
// Obtiene el valor de la variable // Obtiene el valor de la variable
Uint8 getSize(); Uint8 getSize();