working on endgame
This commit is contained in:
@@ -448,28 +448,23 @@ void Director::runGame()
|
|||||||
|
|
||||||
void Director::run()
|
void Director::run()
|
||||||
{
|
{
|
||||||
const std::string text = "españa";
|
|
||||||
printf("lenght = %d\n", text.length());
|
|
||||||
for (int i = 0; i < text.length(); i++)
|
|
||||||
printf("%d - %d\n", i, (unsigned int)text[i]);
|
|
||||||
|
|
||||||
// Bucle principal
|
// Bucle principal
|
||||||
//while (!(getSection() == PROG_SECTION_QUIT))
|
while (!(getSection() == PROG_SECTION_QUIT))
|
||||||
//{
|
{
|
||||||
// switch (getSection())
|
switch (getSection())
|
||||||
// {
|
{
|
||||||
// case PROG_SECTION_LOGO:
|
case PROG_SECTION_LOGO:
|
||||||
// runLogo();
|
runLogo();
|
||||||
// break;
|
break;
|
||||||
// case PROG_SECTION_INTRO:
|
case PROG_SECTION_INTRO:
|
||||||
// runIntro();
|
runIntro();
|
||||||
// break;
|
break;
|
||||||
// case PROG_SECTION_TITLE:
|
case PROG_SECTION_TITLE:
|
||||||
// runTitle();
|
runTitle();
|
||||||
// break;
|
break;
|
||||||
// case PROG_SECTION_GAME:
|
case PROG_SECTION_GAME:
|
||||||
// runGame();
|
runGame();
|
||||||
// break;
|
break;
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
@@ -240,13 +240,15 @@ void Game::init()
|
|||||||
mTicksSpeed = 15;
|
mTicksSpeed = 15;
|
||||||
|
|
||||||
// Inicializa las variables
|
// Inicializa las variables
|
||||||
|
mGameCompleted = false;
|
||||||
|
mGameCompletedCounter = 0;
|
||||||
mSection.name = PROG_SECTION_GAME;
|
mSection.name = PROG_SECTION_GAME;
|
||||||
mSection.subsection = GAME_SECTION_PLAY;
|
mSection.subsection = GAME_SECTION_PLAY;
|
||||||
mMenaceCurrent = 0;
|
mMenaceCurrent = 0;
|
||||||
mMenaceThreshold = 0;
|
mMenaceThreshold = 0;
|
||||||
mScore = 0;
|
mScore = 0;
|
||||||
mHiScoreAchieved = false;
|
mHiScoreAchieved = false;
|
||||||
mCurrentStage = 0;
|
mCurrentStage = 9;
|
||||||
mStageBitmapCounter = STAGE_COUNTER;
|
mStageBitmapCounter = STAGE_COUNTER;
|
||||||
mDeathCounter = DEATH_COUNTER;
|
mDeathCounter = DEATH_COUNTER;
|
||||||
mExplosionTime = false;
|
mExplosionTime = false;
|
||||||
@@ -287,7 +289,7 @@ void Game::init()
|
|||||||
initGameStages();
|
initGameStages();
|
||||||
|
|
||||||
// Modo debug
|
// Modo debug
|
||||||
mDebug.enabled = false;
|
mDebug.enabled = true;
|
||||||
mDebug.enemySet = 0;
|
mDebug.enemySet = 0;
|
||||||
mDebug.gradR = mDebug.gradG = mDebug.gradB = 0;
|
mDebug.gradR = mDebug.gradG = mDebug.gradB = 0;
|
||||||
|
|
||||||
@@ -295,6 +297,9 @@ void Game::init()
|
|||||||
mDemo.recording = false;
|
mDemo.recording = false;
|
||||||
mDemo.counter = 0;
|
mDemo.counter = 0;
|
||||||
|
|
||||||
|
// Iniciualiza el objeto para el fundido
|
||||||
|
mFade->init();
|
||||||
|
|
||||||
// Inicializa los objetos de texto
|
// Inicializa los objetos de texto
|
||||||
mText->init(TEXT_FIXED, BLOCK);
|
mText->init(TEXT_FIXED, BLOCK);
|
||||||
mTextX2->init(TEXT_FIXED, BLOCK * 2);
|
mTextX2->init(TEXT_FIXED, BLOCK * 2);
|
||||||
@@ -353,7 +358,7 @@ void Game::init()
|
|||||||
resetBalloons();
|
resetBalloons();
|
||||||
|
|
||||||
// Con los globos creados, calcula el nivel de amenaza
|
// Con los globos creados, calcula el nivel de amenaza
|
||||||
setMenace();
|
evaluateAndSetMenace();
|
||||||
|
|
||||||
// Establece a cero todos los valores del vector de objetos bala
|
// Establece a cero todos los valores del vector de objetos bala
|
||||||
resetBullets();
|
resetBullets();
|
||||||
@@ -1343,7 +1348,7 @@ void Game::initGameStages()
|
|||||||
|
|
||||||
// STAGE 10
|
// STAGE 10
|
||||||
mStage[9].number = 10;
|
mStage[9].number = 10;
|
||||||
mStage[9].currentPower = 0;
|
mStage[9].currentPower = 900;
|
||||||
mStage[9].powerToComplete = 950;
|
mStage[9].powerToComplete = 950;
|
||||||
mStage[9].minMenace = 7 + (4 * 9);
|
mStage[9].minMenace = 7 + (4 * 9);
|
||||||
mStage[9].maxMenace = 7 + (4 * 15);
|
mStage[9].maxMenace = 7 + (4 * 15);
|
||||||
@@ -1546,6 +1551,16 @@ void Game::updateStage()
|
|||||||
{
|
{
|
||||||
// Cambio de fase
|
// Cambio de fase
|
||||||
mCurrentStage++;
|
mCurrentStage++;
|
||||||
|
if (mCurrentStage == 10)
|
||||||
|
{
|
||||||
|
mGameCompleted = true; // Marca el juego como completado
|
||||||
|
mCurrentStage = 9; // Deja el valor dentro de los limites
|
||||||
|
mStage[mCurrentStage].currentPower = 0; // Deja el poder a cero para que no vuelva a entrar en esta condición
|
||||||
|
destroyAllBalloons(); // Destruye a todos los enemigos
|
||||||
|
mStage[mCurrentStage].currentPower = 0; // Vuelve a dejar el poder a cero, por lo que hubiera podido subir al destruir todos lo globos
|
||||||
|
mMenaceCurrent = 255;
|
||||||
|
JA_StopMusic();
|
||||||
|
}
|
||||||
JA_PlaySound(mSoundStageChange);
|
JA_PlaySound(mSoundStageChange);
|
||||||
mStageBitmapCounter = 0;
|
mStageBitmapCounter = 0;
|
||||||
mEnemySpeed = BALLOON_SPEED_1;
|
mEnemySpeed = BALLOON_SPEED_1;
|
||||||
@@ -1554,8 +1569,14 @@ void Game::updateStage()
|
|||||||
mEffect.shake = true;
|
mEffect.shake = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Incrementa el contador del bitmap que aparece mostrando el cambio de fase
|
||||||
if (mStageBitmapCounter < STAGE_COUNTER)
|
if (mStageBitmapCounter < STAGE_COUNTER)
|
||||||
mStageBitmapCounter++;
|
mStageBitmapCounter++;
|
||||||
|
|
||||||
|
// Si el juego se ha completado, el bitmap se detiene en el centro de la pantalla
|
||||||
|
if (mGameCompleted)
|
||||||
|
if (mStageBitmapCounter > 100)
|
||||||
|
mStageBitmapCounter = 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza el estado de muerte
|
// Actualiza el estado de muerte
|
||||||
@@ -1623,13 +1644,13 @@ void Game::updateDeath()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Renderiza el fade final cuando se acaba la partida
|
// Renderiza el fade final cuando se acaba la partida
|
||||||
void Game::renderDeathFade()
|
void Game::renderDeathFade(bool trigger, int counter)
|
||||||
{
|
{
|
||||||
if (!mPlayer->isAlive() && (mDeathCounter < 150))
|
if ((trigger) && (counter < 150))
|
||||||
{
|
{
|
||||||
// 192 / 6 = 32, 6 cuadrados de 32 pixeles
|
// 192 / 6 = 32, 6 cuadrados de 32 pixeles
|
||||||
SDL_Rect rect[12];
|
SDL_Rect rect[12];
|
||||||
Uint8 h = (150 - mDeathCounter) / 3;
|
Uint8 h = counter / 3;
|
||||||
SDL_SetRenderDrawColor(mRenderer, 0x27, 0x27, 0x36, 255);
|
SDL_SetRenderDrawColor(mRenderer, 0x27, 0x27, 0x36, 255);
|
||||||
for (int i = 0; i < 12; i++)
|
for (int i = 0; i < 12; i++)
|
||||||
{
|
{
|
||||||
@@ -1823,7 +1844,7 @@ void Game::popBalloon(Uint8 index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Recalcula el nivel de amenaza
|
// Recalcula el nivel de amenaza
|
||||||
setMenace();
|
evaluateAndSetMenace();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Explosiona un globo. Lo destruye
|
// Explosiona un globo. Lo destruye
|
||||||
@@ -1874,7 +1895,7 @@ void Game::destroyBalloon(Uint8 index)
|
|||||||
mBalloon[index]->pop();
|
mBalloon[index]->pop();
|
||||||
|
|
||||||
// Recalcula el nivel de amenaza
|
// Recalcula el nivel de amenaza
|
||||||
setMenace();
|
evaluateAndSetMenace();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Explosiona todos los globos
|
// Explosiona todos los globos
|
||||||
@@ -1891,9 +1912,11 @@ void Game::popAllBalloons()
|
|||||||
void Game::destroyAllBalloons()
|
void Game::destroyAllBalloons()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < MAX_BALLOONS; i++)
|
for (int i = 0; i < MAX_BALLOONS; i++)
|
||||||
if ((mBalloon[i]->isEnabled()) && (!mBalloon[i]->isPopping()) && (!mBalloon[i]->isBeingCreated()))
|
//if ((mBalloon[i]->isEnabled()) && (!mBalloon[i]->isPopping()) && (!mBalloon[i]->isBeingCreated()))
|
||||||
|
if ((mBalloon[i]->isEnabled()) && (!mBalloon[i]->isPopping()))
|
||||||
destroyBalloon(i);
|
destroyBalloon(i);
|
||||||
|
|
||||||
|
mEnemyDeployCounter = 255;
|
||||||
JA_PlaySound(mSoundPowerBall);
|
JA_PlaySound(mSoundPowerBall);
|
||||||
mEffect.flash = true;
|
mEffect.flash = true;
|
||||||
mEffect.shake = true;
|
mEffect.shake = true;
|
||||||
@@ -2009,7 +2032,7 @@ void Game::checkBulletBalloonCollision()
|
|||||||
if (!mDemo.enabled)
|
if (!mDemo.enabled)
|
||||||
JA_PlaySound(mSoundBalloon);
|
JA_PlaySound(mSoundBalloon);
|
||||||
mBullet[j]->erase();
|
mBullet[j]->erase();
|
||||||
setMenace();
|
evaluateAndSetMenace();
|
||||||
const Uint8 droppeditem = dropItem();
|
const Uint8 droppeditem = dropItem();
|
||||||
if ((droppeditem != NO_KIND) && !(mDemo.enabled) && !(mDemo.recording))
|
if ((droppeditem != NO_KIND) && !(mDemo.enabled) && !(mDemo.recording))
|
||||||
{
|
{
|
||||||
@@ -2276,7 +2299,7 @@ void Game::killPlayer()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calcula y establece el valor de amenaza en funcion de los globos activos
|
// Calcula y establece el valor de amenaza en funcion de los globos activos
|
||||||
void Game::setMenace()
|
void Game::evaluateAndSetMenace()
|
||||||
{
|
{
|
||||||
mMenaceCurrent = 0;
|
mMenaceCurrent = 0;
|
||||||
for (int i = 0; i < MAX_BALLOONS; i++)
|
for (int i = 0; i < MAX_BALLOONS; i++)
|
||||||
@@ -2419,14 +2442,18 @@ void Game::updatePlayField()
|
|||||||
// Comprueba las colisiones entre globos y balas
|
// Comprueba las colisiones entre globos y balas
|
||||||
checkBulletBalloonCollision();
|
checkBulletBalloonCollision();
|
||||||
|
|
||||||
// Comprueba las colisiones entre elk jugador y los items
|
// Comprueba las colisiones entre el jugador y los items
|
||||||
checkPlayerItemCollision();
|
checkPlayerItemCollision();
|
||||||
|
|
||||||
// Comprueba el nivel de amenaza
|
// Comprueba el nivel de amenaza para ver si se han de crear nuevos enemigos
|
||||||
|
if (!mGameCompleted)
|
||||||
updateMenace();
|
updateMenace();
|
||||||
|
|
||||||
// Actualiza la velocidad de los enemigos
|
// Actualiza la velocidad de los enemigos
|
||||||
updateBalloonSpeed();
|
updateBalloonSpeed();
|
||||||
|
|
||||||
|
// Actualiza el tramo final de juego, una vez completado
|
||||||
|
updateGameCompleted();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza el fondo
|
// Actualiza el fondo
|
||||||
@@ -2494,7 +2521,7 @@ void Game::renderPlayField()
|
|||||||
renderSmartSprites();
|
renderSmartSprites();
|
||||||
mPlayer->render();
|
mPlayer->render();
|
||||||
renderMessages();
|
renderMessages();
|
||||||
renderDeathFade();
|
renderDeathFade(!mPlayer->isAlive(), 150 - mDeathCounter);
|
||||||
renderScoreBoard();
|
renderScoreBoard();
|
||||||
renderFlashEffect();
|
renderFlashEffect();
|
||||||
}
|
}
|
||||||
@@ -2515,7 +2542,7 @@ void Game::updateMenace()
|
|||||||
deployEnemyFormation();
|
deployEnemyFormation();
|
||||||
|
|
||||||
// Recalcula el nivel de amenaza con el nuevo globo
|
// Recalcula el nivel de amenaza con el nuevo globo
|
||||||
setMenace();
|
evaluateAndSetMenace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2704,8 +2731,12 @@ void Game::renderMessages()
|
|||||||
mTextX2->writeDX(TXT_CENTER | TXT_SHADOW, PLAY_AREA_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, mTextStrings[37], 0, noColor, 2, shdwTxtColor);
|
mTextX2->writeDX(TXT_CENTER | TXT_SHADOW, PLAY_AREA_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, mTextStrings[37], 0, noColor, 2, shdwTxtColor);
|
||||||
|
|
||||||
// STAGE NUMBER
|
// STAGE NUMBER
|
||||||
|
std::string text = mTextStrings[38] + std::to_string(mStage[mCurrentStage].number);
|
||||||
|
if (mGameCompleted) // Texto de juego completado
|
||||||
|
text = mTextStrings[50];
|
||||||
|
|
||||||
if (mStageBitmapCounter < STAGE_COUNTER)
|
if (mStageBitmapCounter < STAGE_COUNTER)
|
||||||
mTextX2->writeDX(TXT_CENTER | TXT_SHADOW, PLAY_AREA_CENTER_X, mStageBitmapPath[mStageBitmapCounter], mTextStrings[38] + std::to_string(mStage[mCurrentStage].number), 0, noColor, 2, shdwTxtColor);
|
mTextX2->writeDX(TXT_CENTER | TXT_SHADOW, PLAY_AREA_CENTER_X, mStageBitmapPath[mStageBitmapCounter], text, 0, noColor, 2, shdwTxtColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Habilita el efecto del item de detener el tiempo
|
// Habilita el efecto del item de detener el tiempo
|
||||||
@@ -2788,6 +2819,7 @@ section_t Game::run()
|
|||||||
if ((JA_GetMusicState() == JA_MUSIC_INVALID) || (JA_GetMusicState() == JA_MUSIC_STOPPED))
|
if ((JA_GetMusicState() == JA_MUSIC_INVALID) || (JA_GetMusicState() == JA_MUSIC_STOPPED))
|
||||||
{
|
{
|
||||||
// Reproduce la música
|
// Reproduce la música
|
||||||
|
if (!mGameCompleted)
|
||||||
if (mPlayer->isAlive())
|
if (mPlayer->isAlive())
|
||||||
JA_PlayMusic(mMusicPlaying);
|
JA_PlayMusic(mMusicPlaying);
|
||||||
}
|
}
|
||||||
@@ -3000,14 +3032,12 @@ void Game::runGameOverScreen()
|
|||||||
case 0: // YES
|
case 0: // YES
|
||||||
mSection.name = PROG_SECTION_GAME;
|
mSection.name = PROG_SECTION_GAME;
|
||||||
mSection.subsection = GAME_SECTION_PLAY;
|
mSection.subsection = GAME_SECTION_PLAY;
|
||||||
//JA_StopMusic();
|
|
||||||
init();
|
init();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1: // NO
|
case 1: // NO
|
||||||
mSection.name = PROG_SECTION_TITLE;
|
mSection.name = PROG_SECTION_TITLE;
|
||||||
mSection.subsection = TITLE_SECTION_1;
|
mSection.subsection = TITLE_SECTION_1;
|
||||||
//JA_StopMusic();
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -3073,6 +3103,7 @@ void Game::renderDebugInfo()
|
|||||||
mText->writeShadowed(2, 2 + 7 * BLOCK, "balloons: " + std::to_string(countBalloons()), color);
|
mText->writeShadowed(2, 2 + 7 * BLOCK, "balloons: " + std::to_string(countBalloons()), color);
|
||||||
mText->writeShadowed(2, 2 + 8 * BLOCK, "balloonsPop: " + std::to_string(mBalloonsPopped), color);
|
mText->writeShadowed(2, 2 + 8 * BLOCK, "balloonsPop: " + std::to_string(mBalloonsPopped), color);
|
||||||
mText->writeShadowed(2, 2 + 9 * BLOCK, "(Z-X)ballSped:" + std::to_string(mEnemySpeed), color);
|
mText->writeShadowed(2, 2 + 9 * BLOCK, "(Z-X)ballSped:" + std::to_string(mEnemySpeed), color);
|
||||||
|
mText->writeShadowed(2, 2 + 10 * BLOCK, "EGcounter: " + std::to_string(mGameCompletedCounter), color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3144,3 +3175,13 @@ void Game::initPaths()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Actualiza el tramo final de juego, una vez completado
|
||||||
|
void Game::updateGameCompleted()
|
||||||
|
{
|
||||||
|
if (mGameCompleted)
|
||||||
|
mGameCompletedCounter++;
|
||||||
|
|
||||||
|
if (mGameCompletedCounter >= 300)
|
||||||
|
renderDeathFade(mGameCompleted, 300 - mGameCompletedCounter);
|
||||||
|
}
|
||||||
@@ -159,8 +159,9 @@ private:
|
|||||||
effect_t mEffect; // Variable para gestionar los efectos visuales
|
effect_t mEffect; // Variable para gestionar los efectos visuales
|
||||||
bool mPowerBallEnabled; // Indica si hay una powerball ya activa
|
bool mPowerBallEnabled; // Indica si hay una powerball ya activa
|
||||||
Uint8 mPostFade; // Qué hacer al acabar el fade
|
Uint8 mPostFade; // Qué hacer al acabar el fade
|
||||||
Uint8 mNextProgSection;
|
|
||||||
float mSin[360]; // Vector con los valores del seno para 360 grados
|
float mSin[360]; // Vector con los valores del seno para 360 grados
|
||||||
|
bool mGameCompleted; // Indica si se ha completado la partida, llegando al final de la ultima pantalla
|
||||||
|
int mGameCompletedCounter; // Contador para el tramo final, cuando se ha completado la partida y ya no aparecen más enemigos
|
||||||
|
|
||||||
struct demo_t
|
struct demo_t
|
||||||
{
|
{
|
||||||
@@ -249,7 +250,7 @@ public:
|
|||||||
void updateDeath();
|
void updateDeath();
|
||||||
|
|
||||||
// Renderiza el fade final cuando se acaba la partida
|
// Renderiza el fade final cuando se acaba la partida
|
||||||
void renderDeathFade();
|
void renderDeathFade(bool trigger, int counter);
|
||||||
|
|
||||||
// Actualiza los globos
|
// Actualiza los globos
|
||||||
void updateBalloons();
|
void updateBalloons();
|
||||||
@@ -378,7 +379,7 @@ public:
|
|||||||
Uint8 getSubsection();
|
Uint8 getSubsection();
|
||||||
|
|
||||||
// Calcula y establece el valor de amenaza en funcion de los globos activos
|
// Calcula y establece el valor de amenaza en funcion de los globos activos
|
||||||
void setMenace();
|
void evaluateAndSetMenace();
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
// Obtiene el valor de la variable
|
||||||
Uint8 getMenace();
|
Uint8 getMenace();
|
||||||
@@ -466,6 +467,9 @@ public:
|
|||||||
|
|
||||||
// Inicializa las variables que contienen puntos de ruta para mover objetos
|
// Inicializa las variables que contienen puntos de ruta para mover objetos
|
||||||
void initPaths();
|
void initPaths();
|
||||||
|
|
||||||
|
// Actualiza el tramo final de juego, una vez completado
|
||||||
|
void updateGameCompleted();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -265,6 +265,11 @@ const std::string gTextStrings[MAX_TEXT_STRINGS][3] =
|
|||||||
"NO",
|
"NO",
|
||||||
"NO"},
|
"NO"},
|
||||||
|
|
||||||
|
// 50 - TEXTO DE COMPLETAR EL JUEGO
|
||||||
|
{"FELICIDADES!!",
|
||||||
|
"FELICITATS!!",
|
||||||
|
"CONGRATULATIONS!!"},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void initTextStrings(std::string *textStrings, Uint8 lang);
|
void initTextStrings(std::string *textStrings, Uint8 lang);
|
||||||
|
|||||||
Reference in New Issue
Block a user