working on 2p
This commit is contained in:
@@ -153,9 +153,10 @@ const int SCREEN_THIRD_QUARTER_Y = (SCREEN_HEIGHT / 4) * 3;
|
||||
#define PROG_SECTION_QUIT 4
|
||||
|
||||
// Subsecciones
|
||||
#define GAME_SECTION_PLAY 0
|
||||
#define GAME_SECTION_PAUSE 1
|
||||
#define GAME_SECTION_GAMEOVER 2
|
||||
#define GAME_SECTION_PLAY_1P 0
|
||||
#define GAME_SECTION_PLAY_2P 1
|
||||
#define GAME_SECTION_PAUSE 2
|
||||
#define GAME_SECTION_GAMEOVER 3
|
||||
#define TITLE_SECTION_1 3
|
||||
#define TITLE_SECTION_2 4
|
||||
#define TITLE_SECTION_3 5
|
||||
|
||||
@@ -467,7 +467,10 @@ void Director::runTitle()
|
||||
|
||||
void Director::runGame()
|
||||
{
|
||||
mGame = new Game(2, mRenderer, mFileList, mTextStrings, mInput1, mInput2, false);
|
||||
if (mSection.subsection == GAME_SECTION_PLAY_1P)
|
||||
mGame = new Game(1, mRenderer, mFileList, mTextStrings, mInput1, mInput2, false);
|
||||
if (mSection.subsection == GAME_SECTION_PLAY_2P)
|
||||
mGame = new Game(2, mRenderer, mFileList, mTextStrings, mInput1, mInput2, false);
|
||||
setSection(mGame->run());
|
||||
delete mGame;
|
||||
}
|
||||
|
||||
232
source/game.cpp
232
source/game.cpp
@@ -274,10 +274,11 @@ void Game::init()
|
||||
mGameCompleted = false;
|
||||
mGameCompletedCounter = 0;
|
||||
mSection.name = PROG_SECTION_GAME;
|
||||
mSection.subsection = GAME_SECTION_PLAY;
|
||||
mSection.subsection = GAME_SECTION_PLAY_1P;
|
||||
mMenaceCurrent = 0;
|
||||
mMenaceThreshold = 0;
|
||||
mScore = 0;
|
||||
//mScore = 0;
|
||||
mHiScore = 0;
|
||||
mHiScoreAchieved = false;
|
||||
mCurrentStage = 0;
|
||||
mStageBitmapCounter = STAGE_COUNTER;
|
||||
@@ -395,11 +396,11 @@ void Game::init()
|
||||
|
||||
// Vector de jugadores
|
||||
if (mNumPlayers == 1)
|
||||
mPlayer[0]->init(PLAY_AREA_CENTER_X - 11, PLAY_AREA_BOTTOM - 24, mTexturePlayer1Legs, mTexturePlayer1Body, mTexturePlayer1Head, mRenderer);
|
||||
mPlayer[0]->init(PLAY_AREA_CENTER_X - 11, PLAY_AREA_BOTTOM - 24, mTexturePlayer1Legs, mTexturePlayer1Body, mTexturePlayer1Head, mTexturePlayer1Death, mRenderer);
|
||||
if (mNumPlayers == 2)
|
||||
{
|
||||
mPlayer[0]->init((PLAY_AREA_CENTER_FIRST_QUARTER_X * ((0 * 2) + 1)) - 11, PLAY_AREA_BOTTOM - 24, mTexturePlayer1Legs, mTexturePlayer1Body, mTexturePlayer1Head, mRenderer);
|
||||
mPlayer[1]->init((PLAY_AREA_CENTER_FIRST_QUARTER_X * ((1 * 2) + 1)) - 11, PLAY_AREA_BOTTOM - 24, mTexturePlayer2Legs, mTexturePlayer2Body, mTexturePlayer2Head, mRenderer);
|
||||
mPlayer[0]->init((PLAY_AREA_CENTER_FIRST_QUARTER_X * ((0 * 2) + 1)) - 11, PLAY_AREA_BOTTOM - 24, mTexturePlayer1Legs, mTexturePlayer1Body, mTexturePlayer1Head, mTexturePlayer1Death, mRenderer);
|
||||
mPlayer[1]->init((PLAY_AREA_CENTER_FIRST_QUARTER_X * ((1 * 2) + 1)) - 11, PLAY_AREA_BOTTOM - 24, mTexturePlayer2Legs, mTexturePlayer2Body, mTexturePlayer2Head, mTexturePlayer2Death, mRenderer);
|
||||
}
|
||||
|
||||
// Establece a cero todos los valores del vector de objetos globo
|
||||
@@ -1467,10 +1468,10 @@ void Game::increaseStageCurrentPower(Uint8 power)
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void Game::setScore(Uint32 score)
|
||||
/*void Game::setScore(Uint32 score)
|
||||
{
|
||||
mScore = score;
|
||||
}
|
||||
}*/
|
||||
|
||||
// Establece el valor de la variable
|
||||
void Game::setHiScore(Uint32 score)
|
||||
@@ -1481,23 +1482,24 @@ void Game::setHiScore(Uint32 score)
|
||||
// Actualiza el valor de mHiScore en caso necesario
|
||||
void Game::updateHiScore()
|
||||
{
|
||||
// La puntuación es mayor que la máxima puntuación
|
||||
if (mScore > mHiScore)
|
||||
{
|
||||
// Actualiza la máxima puntuación
|
||||
mHiScore = mScore;
|
||||
|
||||
// Almacena la máxima puntuación en el fichero junto con un checksum
|
||||
mScoreDataFile[0] = mHiScore;
|
||||
mScoreDataFile[1] = mHiScore % 43;
|
||||
|
||||
// Si superamos la máxima puntuación
|
||||
if (mHiScoreAchieved == false)
|
||||
// Si la puntuación actual es mayor que la máxima puntuación
|
||||
for (int i = 0; i < mNumPlayers; i++)
|
||||
if (mPlayer[i]->getScore() > mHiScore)
|
||||
{
|
||||
mHiScoreAchieved = true;
|
||||
JA_PlaySound(mSoundHiScore);
|
||||
// Actualiza la máxima puntuación
|
||||
mHiScore = mPlayer[i]->getScore();
|
||||
|
||||
// Almacena la máxima puntuación en el fichero junto con un checksum
|
||||
mScoreDataFile[0] = mHiScore;
|
||||
mScoreDataFile[1] = mHiScore % 43;
|
||||
|
||||
// Si se supera la máxima puntuación emite sonido
|
||||
if (mHiScoreAchieved == false)
|
||||
{
|
||||
mHiScoreAchieved = true;
|
||||
JA_PlaySound(mSoundHiScore);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Transforma un valor numérico en una cadena de 6 cifras
|
||||
@@ -1554,7 +1556,7 @@ void Game::renderScoreBoard()
|
||||
|
||||
// SCORE
|
||||
mText->writeCentered(PLAY_AREA_CENTER_FIRST_QUARTER_X, SCORE_WORD_Y - 6, mTextStrings[39], 0);
|
||||
mText->writeCentered(PLAY_AREA_CENTER_FIRST_QUARTER_X, SCORE_NUMBER_Y - 6, updateScoreText(mScore), 0);
|
||||
mText->writeCentered(PLAY_AREA_CENTER_FIRST_QUARTER_X, SCORE_NUMBER_Y - 6, updateScoreText(mPlayer[0]->getScore()), 0);
|
||||
|
||||
// HI-SCORE
|
||||
mText->writeCentered(PLAY_AREA_CENTER_THIRD_QUARTER_X, HISCORE_WORD_Y - 6, mTextStrings[40], 0);
|
||||
@@ -1588,16 +1590,19 @@ void Game::updatePlayer()
|
||||
mPlayer[i]->update();
|
||||
|
||||
// Comprueba la colisión entre el jugador y los globos
|
||||
if (checkPlayerBalloonCollision())
|
||||
if (checkPlayerBalloonCollision(i))
|
||||
{
|
||||
if (mPlayer[i]->isAlive())
|
||||
{
|
||||
if (mDemo.enabled)
|
||||
mSection = {PROG_SECTION_TITLE, TITLE_SECTION_INSTRUCTIONS};
|
||||
else
|
||||
killPlayer();
|
||||
killPlayer(i);
|
||||
}
|
||||
}
|
||||
|
||||
// Comprueba las colisiones entre el jugador y los items
|
||||
checkPlayerItemCollision(i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1639,7 +1644,12 @@ void Game::updateStage()
|
||||
// Actualiza el estado de muerte
|
||||
void Game::updateDeath()
|
||||
{
|
||||
if (!mPlayer[0]->isAlive())
|
||||
// Comprueba si todos los jugadores estan muertos
|
||||
bool allPlayersAreDead = true;
|
||||
for (int i = 0; i < mNumPlayers; i++)
|
||||
allPlayersAreDead &= (!mPlayer[i]->isAlive());
|
||||
|
||||
if (allPlayersAreDead)
|
||||
{
|
||||
if (mDeathCounter > 0)
|
||||
{
|
||||
@@ -1948,7 +1958,7 @@ void Game::destroyBalloon(Uint8 index)
|
||||
|
||||
// Otorga los puntos correspondientes al globo
|
||||
mPlayer[0]->addScore(Uint32(score * mPlayer[0]->getScoreMultiplier()));
|
||||
setScore(mPlayer[0]->getScore());
|
||||
//setScore(mPlayer[0]->getScore());
|
||||
updateHiScore();
|
||||
|
||||
// Aumenta el poder de la fase
|
||||
@@ -2022,73 +2032,70 @@ Uint8 Game::countBalloons()
|
||||
}
|
||||
|
||||
// Comprueba la colisión entre el jugador y los globos activos
|
||||
bool Game::checkPlayerBalloonCollision()
|
||||
bool Game::checkPlayerBalloonCollision(int index)
|
||||
{
|
||||
for (int j = 0; j < mNumPlayers; j++)
|
||||
for (int i = 0; i < MAX_BALLOONS; i++)
|
||||
if ((mBalloon[i]->isEnabled()) && !(mBalloon[i]->isStopped()) && !(mBalloon[i]->isInvulnerable()))
|
||||
if (checkCollision(mPlayer[j]->getCollider(), mBalloon[i]->getCollider()))
|
||||
return true;
|
||||
for (int i = 0; i < MAX_BALLOONS; i++)
|
||||
if ((mBalloon[i]->isEnabled()) && !(mBalloon[i]->isStopped()) && !(mBalloon[i]->isInvulnerable()))
|
||||
if (checkCollision(mPlayer[index]->getCollider(), mBalloon[i]->getCollider()))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Comprueba la colisión entre el jugador y los items
|
||||
void Game::checkPlayerItemCollision()
|
||||
void Game::checkPlayerItemCollision(int index)
|
||||
{
|
||||
for (int j = 0; j < mNumPlayers; j++)
|
||||
|
||||
if (mPlayer[j]->isAlive())
|
||||
for (int i = 0; i < MAX_ITEMS; i++)
|
||||
if (mPlayer[index]->isAlive())
|
||||
for (int i = 0; i < MAX_ITEMS; i++)
|
||||
{
|
||||
if (mItem[i]->isEnabled())
|
||||
{
|
||||
if (mItem[i]->isEnabled())
|
||||
if (checkCollision(mPlayer[index]->getCollider(), mItem[i]->getCollider()))
|
||||
{
|
||||
if (checkCollision(mPlayer[j]->getCollider(), mItem[i]->getCollider()))
|
||||
switch (mItem[i]->getClass())
|
||||
{
|
||||
switch (mItem[i]->getClass())
|
||||
{
|
||||
case ITEM_POINTS_1_DISK:
|
||||
mPlayer[j]->addScore(1000);
|
||||
setScore(mPlayer[j]->getScore());
|
||||
updateHiScore();
|
||||
createItemScoreSprite(mItem[i]->getPosX() + (mItem[i]->getWidth() / 2) - (m1000Bitmap->getWidth() / 2), mPlayer[j]->getPosY(), m1000Bitmap);
|
||||
JA_PlaySound(mSoundItemPickup);
|
||||
break;
|
||||
case ITEM_POINTS_2_GAVINA:
|
||||
mPlayer[j]->addScore(2500);
|
||||
setScore(mPlayer[j]->getScore());
|
||||
updateHiScore();
|
||||
createItemScoreSprite(mItem[i]->getPosX() + (mItem[i]->getWidth() / 2) - (m2500Bitmap->getWidth() / 2), mPlayer[j]->getPosY(), m2500Bitmap);
|
||||
JA_PlaySound(mSoundItemPickup);
|
||||
break;
|
||||
case ITEM_POINTS_3_PACMAR:
|
||||
mPlayer[j]->addScore(5000);
|
||||
setScore(mPlayer[j]->getScore());
|
||||
updateHiScore();
|
||||
createItemScoreSprite(mItem[i]->getPosX() + (mItem[i]->getWidth() / 2) - (m5000Bitmap->getWidth() / 2), mPlayer[j]->getPosY(), m5000Bitmap);
|
||||
JA_PlaySound(mSoundItemPickup);
|
||||
break;
|
||||
case ITEM_CLOCK:
|
||||
enableTimeStopItem();
|
||||
JA_PlaySound(mSoundItemPickup);
|
||||
break;
|
||||
case ITEM_COFFEE:
|
||||
mPlayer[j]->giveExtraHit();
|
||||
JA_PlaySound(mSoundItemPickup);
|
||||
break;
|
||||
case ITEM_COFFEE_MACHINE:
|
||||
mPlayer[j]->setPowerUp(true);
|
||||
JA_PlaySound(mSoundItemPickup);
|
||||
mCoffeeMachineEnabled = false;
|
||||
break;
|
||||
case ITEM_POINTS_1_DISK:
|
||||
mPlayer[index]->addScore(1000);
|
||||
//setScore(mPlayer[index]->getScore());
|
||||
updateHiScore();
|
||||
createItemScoreSprite(mItem[i]->getPosX() + (mItem[i]->getWidth() / 2) - (m1000Bitmap->getWidth() / 2), mPlayer[index]->getPosY(), m1000Bitmap);
|
||||
JA_PlaySound(mSoundItemPickup);
|
||||
break;
|
||||
case ITEM_POINTS_2_GAVINA:
|
||||
mPlayer[index]->addScore(2500);
|
||||
//setScore(mPlayer[index]->getScore());
|
||||
updateHiScore();
|
||||
createItemScoreSprite(mItem[i]->getPosX() + (mItem[i]->getWidth() / 2) - (m2500Bitmap->getWidth() / 2), mPlayer[index]->getPosY(), m2500Bitmap);
|
||||
JA_PlaySound(mSoundItemPickup);
|
||||
break;
|
||||
case ITEM_POINTS_3_PACMAR:
|
||||
mPlayer[index]->addScore(5000);
|
||||
//setScore(mPlayer[index]->getScore());
|
||||
updateHiScore();
|
||||
createItemScoreSprite(mItem[i]->getPosX() + (mItem[i]->getWidth() / 2) - (m5000Bitmap->getWidth() / 2), mPlayer[index]->getPosY(), m5000Bitmap);
|
||||
JA_PlaySound(mSoundItemPickup);
|
||||
break;
|
||||
case ITEM_CLOCK:
|
||||
enableTimeStopItem();
|
||||
JA_PlaySound(mSoundItemPickup);
|
||||
break;
|
||||
case ITEM_COFFEE:
|
||||
mPlayer[index]->giveExtraHit();
|
||||
JA_PlaySound(mSoundItemPickup);
|
||||
break;
|
||||
case ITEM_COFFEE_MACHINE:
|
||||
mPlayer[index]->setPowerUp(true);
|
||||
JA_PlaySound(mSoundItemPickup);
|
||||
mCoffeeMachineEnabled = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
mItem[i]->erase();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
mItem[i]->erase();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Comprueba y procesa la colisión entre las balas y los globos
|
||||
@@ -2103,7 +2110,7 @@ void Game::checkBulletBalloonCollision()
|
||||
const int index = mBullet[j]->getOwner();
|
||||
mPlayer[index]->incScoreMultiplier();
|
||||
mPlayer[index]->addScore(Uint32(mBalloon[i]->getScore() * mPlayer[index]->getScoreMultiplier()));
|
||||
setScore(mPlayer[index]->getScore());
|
||||
//setScore(mPlayer[index]->getScore());
|
||||
updateHiScore();
|
||||
|
||||
// Explota el globo
|
||||
@@ -2339,12 +2346,16 @@ void Game::throwCoffee(int x, int y)
|
||||
}
|
||||
|
||||
// Crea un SmartSprite para arrojar al jugador al morir
|
||||
void Game::throwPlayer(int x, int y)
|
||||
void Game::throwPlayer(int x, int y, int index)
|
||||
{
|
||||
const int sentit = ((rand() % 2) ? 1 : -1);
|
||||
|
||||
mDeathIndex = getSmartSpriteFreeIndex();
|
||||
mSmartSprite[mDeathIndex]->init(mTexturePlayer1Death, mRenderer);
|
||||
/*if (index == 1)
|
||||
mSmartSprite[mDeathIndex]->init(mTexturePlayer1Death, mRenderer);
|
||||
if (index == 2)
|
||||
mSmartSprite[mDeathIndex]->init(mTexturePlayer2Death, mRenderer);*/
|
||||
mSmartSprite[mDeathIndex]->init(mPlayer[index]->getDeadTexture(), mRenderer);
|
||||
mSmartSprite[mDeathIndex]->setPosX(x);
|
||||
mSmartSprite[mDeathIndex]->setPosY(y);
|
||||
mSmartSprite[mDeathIndex]->setWidth(24);
|
||||
@@ -2392,30 +2403,28 @@ void Game::resetSmartSprites()
|
||||
}
|
||||
|
||||
// Acciones a realizar cuando el jugador muere
|
||||
void Game::killPlayer()
|
||||
void Game::killPlayer(int index)
|
||||
{
|
||||
for (int i = 0; i < mNumPlayers; i++)
|
||||
|
||||
if (!mPlayer[i]->isInvulnerable())
|
||||
if (!mPlayer[index]->isInvulnerable())
|
||||
{
|
||||
if (mPlayer[index]->hasExtraHit())
|
||||
{
|
||||
if (mPlayer[i]->hasExtraHit())
|
||||
{
|
||||
mPlayer[i]->removeExtraHit();
|
||||
throwCoffee(mPlayer[i]->getPosX() + (mPlayer[i]->getWidth() / 2), mPlayer[i]->getPosY() + (mPlayer[i]->getHeight() / 2));
|
||||
JA_PlaySound(mSoundCoffeeOut);
|
||||
}
|
||||
else
|
||||
{
|
||||
stopAllBalloons(10);
|
||||
JA_StopMusic();
|
||||
JA_PlaySound(mSoundPlayerCollision);
|
||||
shakeScreen();
|
||||
SDL_Delay(500);
|
||||
JA_PlaySound(mSoundCoffeeOut);
|
||||
throwPlayer(mPlayer[i]->getPosX(), mPlayer[i]->getPosY());
|
||||
mPlayer[i]->setAlive(false);
|
||||
}
|
||||
mPlayer[index]->removeExtraHit();
|
||||
throwCoffee(mPlayer[index]->getPosX() + (mPlayer[index]->getWidth() / 2), mPlayer[index]->getPosY() + (mPlayer[index]->getHeight() / 2));
|
||||
JA_PlaySound(mSoundCoffeeOut);
|
||||
}
|
||||
else
|
||||
{
|
||||
stopAllBalloons(10);
|
||||
JA_StopMusic();
|
||||
JA_PlaySound(mSoundPlayerCollision);
|
||||
shakeScreen();
|
||||
SDL_Delay(500);
|
||||
JA_PlaySound(mSoundCoffeeOut);
|
||||
throwPlayer(mPlayer[index]->getPosX(), mPlayer[index]->getPosY(), index);
|
||||
mPlayer[index]->setAlive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Calcula y establece el valor de amenaza en funcion de los globos activos
|
||||
@@ -2565,9 +2574,6 @@ void Game::updatePlayField()
|
||||
// Comprueba las colisiones entre globos y balas
|
||||
checkBulletBalloonCollision();
|
||||
|
||||
// Comprueba las colisiones entre el jugador y los items
|
||||
checkPlayerItemCollision();
|
||||
|
||||
// Comprueba el nivel de amenaza para ver si se han de crear nuevos enemigos
|
||||
if (!mGameCompleted)
|
||||
updateMenace();
|
||||
@@ -2944,7 +2950,7 @@ section_t Game::run()
|
||||
runGameOverScreen();
|
||||
|
||||
// Sección juego jugando
|
||||
if (mSection.subsection == GAME_SECTION_PLAY)
|
||||
if ((mSection.subsection == GAME_SECTION_PLAY_1P) || (mSection.subsection == GAME_SECTION_PLAY_2P))
|
||||
{
|
||||
// Si la música no está sonando
|
||||
if ((JA_GetMusicState() == JA_MUSIC_INVALID) || (JA_GetMusicState() == JA_MUSIC_STOPPED))
|
||||
@@ -3112,7 +3118,10 @@ void Game::runPausedGame()
|
||||
case 0:
|
||||
//mMenuPause->reset();
|
||||
mSection.name = PROG_SECTION_GAME;
|
||||
mSection.subsection = GAME_SECTION_PLAY;
|
||||
if (mNumPlayers == 1)
|
||||
mSection.subsection = GAME_SECTION_PLAY_1P;
|
||||
else
|
||||
mSection.subsection = GAME_SECTION_PLAY_2P;
|
||||
if (JA_GetMusicState() == JA_MUSIC_PAUSED)
|
||||
JA_ResumeMusic();
|
||||
break;
|
||||
@@ -3163,7 +3172,10 @@ void Game::runGameOverScreen()
|
||||
{
|
||||
case 0: // YES
|
||||
mSection.name = PROG_SECTION_GAME;
|
||||
mSection.subsection = GAME_SECTION_PLAY;
|
||||
if (mNumPlayers == 1)
|
||||
mSection.subsection = GAME_SECTION_PLAY_1P;
|
||||
else
|
||||
mSection.subsection = GAME_SECTION_PLAY_2P;
|
||||
init();
|
||||
break;
|
||||
|
||||
|
||||
@@ -82,10 +82,10 @@ private:
|
||||
SDL_Renderer *mRenderer; // El renderizador de la ventana
|
||||
std::string *mFileList; // Lista de ficheros con los recursos
|
||||
std::string *mTextStrings; // Vector con los textos del juego
|
||||
Input *mInput[2]; // Manejador de entrada
|
||||
|
||||
int mNumPlayers; // Numero de jugadores
|
||||
Player *mPlayer[2]; // Vector con los jugadores jugador
|
||||
Input *mInput[2]; // Manejador de entrada, uno por cada jugador
|
||||
|
||||
Balloon *mBalloon[MAX_BALLOONS]; // Vector con los objetos globo
|
||||
Bullet *mBullet[MAX_BULLETS]; // Vector con los objetos bala
|
||||
@@ -152,7 +152,7 @@ private:
|
||||
Uint32 mTicks; // Contador de ticks para ajustar la velocidad del programa
|
||||
Uint8 mTicksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||
|
||||
Uint32 mScore; // Puntuación actual
|
||||
//Uint32 mScore; // Puntuación actual
|
||||
Uint32 mHiScore; // Puntuación máxima
|
||||
bool mHiScoreAchieved; // Indica si se ha superado la puntuación máxima
|
||||
section_t mSection; // Seccion actual dentro del juego
|
||||
@@ -249,7 +249,7 @@ public:
|
||||
void increaseStageCurrentPower(Uint8 power);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setScore(Uint32 score);
|
||||
//void setScore(Uint32 score);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setHiScore(Uint32 score);
|
||||
@@ -327,10 +327,10 @@ public:
|
||||
Uint8 countBalloons();
|
||||
|
||||
// Comprueba la colisión entre el jugador y los globos activos
|
||||
bool checkPlayerBalloonCollision();
|
||||
bool checkPlayerBalloonCollision(int index);
|
||||
|
||||
// Comprueba la colisión entre el jugador y los items
|
||||
void checkPlayerItemCollision();
|
||||
void checkPlayerItemCollision(int index);
|
||||
|
||||
// Comprueba la colisión entre las balas y los globos
|
||||
void checkBulletBalloonCollision();
|
||||
@@ -381,7 +381,7 @@ public:
|
||||
void throwCoffee(int x, int y);
|
||||
|
||||
// Crea un SmartSprite para arrojar al jugador al morir
|
||||
void throwPlayer(int x, int y);
|
||||
void throwPlayer(int x, int y, int index);
|
||||
|
||||
// Actualiza los SmartSprites
|
||||
void updateSmartSprites();
|
||||
@@ -396,7 +396,7 @@ public:
|
||||
void resetSmartSprites();
|
||||
|
||||
// Acciones a realizar cuando el jugador muere
|
||||
void killPlayer();
|
||||
void killPlayer(int index);
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
Uint8 getSubsection();
|
||||
|
||||
@@ -270,6 +270,16 @@ const std::string gTextStrings[MAX_TEXT_STRINGS][3] =
|
||||
"FELICITATS!!",
|
||||
"NICE!!"},
|
||||
|
||||
// 51 - MENU DEL TITULO (1 JUGADOR)
|
||||
{"1 JUGADOR",
|
||||
"1 JUGADOR",
|
||||
"1 PLAYER"},
|
||||
|
||||
// 52 - MENU DEL TITULO (2 JUGADORES)
|
||||
{"2 JUGADORES",
|
||||
"2 JUGADORS",
|
||||
"2 PLAYERS"},
|
||||
|
||||
};
|
||||
|
||||
void initTextStrings(std::string *textStrings, Uint8 lang);
|
||||
|
||||
@@ -23,8 +23,11 @@ Player::~Player()
|
||||
}
|
||||
|
||||
// Iniciador
|
||||
void Player::init(float x, int y, LTexture *textureLegs, LTexture *textureBody, LTexture *textureHead, SDL_Renderer *renderer)
|
||||
void Player::init(float x, int y, LTexture *textureLegs, LTexture *textureBody, LTexture *textureHead, LTexture *textureDead, SDL_Renderer *renderer)
|
||||
{
|
||||
// Copia punteros
|
||||
mPlayerDeadTexture = textureDead;
|
||||
|
||||
// Inicializa variables de estado
|
||||
mAlive = true;
|
||||
mStatusWalking = PLAYER_STATUS_WALKING_STOP;
|
||||
@@ -545,19 +548,19 @@ void Player::update()
|
||||
}
|
||||
|
||||
// Obtiene la puntuación del jugador
|
||||
int Player::getScore()
|
||||
Uint32 Player::getScore()
|
||||
{
|
||||
return mScore;
|
||||
}
|
||||
|
||||
// Asigna un valor a la puntuación del jugador
|
||||
void Player::setScore(int score)
|
||||
void Player::setScore(Uint32 score)
|
||||
{
|
||||
mScore = score;
|
||||
}
|
||||
|
||||
// Incrementa la puntuación del jugador
|
||||
void Player::addScore(int score)
|
||||
void Player::addScore(Uint32 score)
|
||||
{
|
||||
mScore += score;
|
||||
}
|
||||
@@ -736,3 +739,9 @@ void Player::shiftColliders()
|
||||
mCollider.x = Uint16(mPosX + (mWidth / 2));
|
||||
mCollider.y = mPosY + (mHeight / 2);
|
||||
}
|
||||
|
||||
// Obtiene el puntero a la textura con los gráficos de la animación de morir
|
||||
LTexture *Player::getDeadTexture()
|
||||
{
|
||||
return mPlayerDeadTexture;
|
||||
}
|
||||
@@ -37,9 +37,10 @@ private:
|
||||
Uint16 mPowerUpCounter; // Temporizador para el modo PowerUp
|
||||
bool mInput; // Indica si puede recibir ordenes de entrada
|
||||
|
||||
AnimatedSprite *mSpriteLegs; // Sprite para dibujar las piernas
|
||||
AnimatedSprite *mSpriteBody; // Sprite para dibujar el cuerpo
|
||||
AnimatedSprite *mSpriteHead; // Sprite para dibujar la cabeza
|
||||
AnimatedSprite *mSpriteLegs; // Sprite para dibujar las piernas
|
||||
AnimatedSprite *mSpriteBody; // Sprite para dibujar el cuerpo
|
||||
AnimatedSprite *mSpriteHead; // Sprite para dibujar la cabeza
|
||||
LTexture *mPlayerDeadTexture; // Textura con los gráficos para la animación de muerte
|
||||
|
||||
circle_t mCollider; // Circulo de colisión del jugador
|
||||
void shiftColliders(); // Actualiza el circulo de colisión a la posición del jugador
|
||||
@@ -52,7 +53,7 @@ public:
|
||||
~Player();
|
||||
|
||||
// Iniciador
|
||||
void init(float x, int y, LTexture *textureLegs, LTexture *textureBody, LTexture *textureHead, SDL_Renderer *renderer);
|
||||
void init(float x, int y, LTexture *textureLegs, LTexture *textureBody, LTexture *textureHead, LTexture *textureDead, SDL_Renderer *renderer);
|
||||
|
||||
// Actua en consecuencia de la entrada recibida
|
||||
void setInput(Uint8 input);
|
||||
@@ -95,13 +96,13 @@ public:
|
||||
void update();
|
||||
|
||||
// Obtiene la puntuación del jugador
|
||||
int getScore();
|
||||
Uint32 getScore();
|
||||
|
||||
// Asigna un valor a la puntuación del jugador
|
||||
void setScore(int score);
|
||||
void setScore(Uint32 score);
|
||||
|
||||
// Incrementa la puntuación del jugador
|
||||
void addScore(int score);
|
||||
void addScore(Uint32 score);
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
bool isAlive();
|
||||
@@ -171,6 +172,9 @@ public:
|
||||
|
||||
// Obtiene el circulo de colisión
|
||||
circle_t &getCollider();
|
||||
|
||||
// Obtiene el puntero a la textura con los gráficos de la animación de morir
|
||||
LTexture *getDeadTexture();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -224,12 +224,13 @@ void Title::init(bool demo, Uint8 subsection)
|
||||
}
|
||||
|
||||
// Inicializa los objetos de menu
|
||||
mMenu.title->init("TITLE", 0, 15 * BLOCK, MENU_BACKGROUND_SOLID);
|
||||
mMenu.title->addItem(mTextStrings[0]); // PLAY
|
||||
mMenu.title->init("TITLE", 0, 14 * BLOCK, MENU_BACKGROUND_SOLID);
|
||||
mMenu.title->addItem(mTextStrings[51]); // 1 PLAYER
|
||||
mMenu.title->addItem(mTextStrings[52]); // 2 PLAYERS
|
||||
mMenu.title->addItem(mTextStrings[1]); // OPTIONS
|
||||
mMenu.title->addItem(mTextStrings[2], 0, 5); // HOW TO PLAY
|
||||
mMenu.title->addItem(mTextStrings[3]); // QUIT
|
||||
mMenu.title->setDefaultActionWhenCancel(3);
|
||||
mMenu.title->setDefaultActionWhenCancel(4);
|
||||
mMenu.title->setBackgroundColor(0x30, 0x30, 0x40, 192);
|
||||
mMenu.title->setSelectorColor(0xe5, 0x1c, 0x23, 255);
|
||||
mMenu.title->setSelectorTextColor(0xFF, 0xF1, 0x76);
|
||||
@@ -335,10 +336,11 @@ void Title::updateMenuLabels()
|
||||
mMenu.options->centerMenu(SCREEN_CENTER_X);
|
||||
mMenu.options->centerMenuElements();
|
||||
|
||||
mMenu.title->setItemCaption(0, mTextStrings[0]);
|
||||
mMenu.title->setItemCaption(1, mTextStrings[1]);
|
||||
mMenu.title->setItemCaption(2, mTextStrings[2]);
|
||||
mMenu.title->setItemCaption(3, mTextStrings[3]);
|
||||
mMenu.title->setItemCaption(0, mTextStrings[51]);
|
||||
mMenu.title->setItemCaption(1, mTextStrings[52]);
|
||||
mMenu.title->setItemCaption(2, mTextStrings[1]);
|
||||
mMenu.title->setItemCaption(3, mTextStrings[2]);
|
||||
mMenu.title->setItemCaption(4, mTextStrings[3]);
|
||||
|
||||
mMenu.title->centerMenu(SCREEN_CENTER_X);
|
||||
mMenu.title->centerMenuElements();
|
||||
@@ -494,17 +496,24 @@ section_t Title::run(Uint8 subsection)
|
||||
{
|
||||
switch (mPostFade)
|
||||
{
|
||||
case 0: // PLAY
|
||||
case 0: // 1 PLAYER
|
||||
mSection.name = PROG_SECTION_GAME;
|
||||
mSection.subsection = GAME_SECTION_PLAY_1P;
|
||||
JA_StopMusic();
|
||||
break;
|
||||
|
||||
case 1: // QUIT
|
||||
case 1: // 2 PLAYERS
|
||||
mSection.name = PROG_SECTION_GAME;
|
||||
mSection.subsection = GAME_SECTION_PLAY_2P;
|
||||
JA_StopMusic();
|
||||
break;
|
||||
|
||||
case 2: // QUIT
|
||||
mSection.name = PROG_SECTION_QUIT;
|
||||
JA_StopMusic();
|
||||
break;
|
||||
|
||||
case 2: // TIME OUT
|
||||
case 3: // TIME OUT
|
||||
mCounter = TITLE_COUNTER;
|
||||
mMenu.active->reset();
|
||||
if (mDemo)
|
||||
@@ -531,21 +540,25 @@ section_t Title::run(Uint8 subsection)
|
||||
{
|
||||
switch (mMenu.active->getItemSelected())
|
||||
{
|
||||
case 0: // PLAY
|
||||
case 0: // 1 PLAYER
|
||||
mPostFade = 0;
|
||||
mFade->activateFade();
|
||||
break;
|
||||
case 1: // OPTIONS
|
||||
case 1: // 2 PLAYERS
|
||||
mPostFade = 1;
|
||||
mFade->activateFade();
|
||||
break;
|
||||
case 2: // OPTIONS
|
||||
mMenu.active = mMenu.options;
|
||||
mOptions->fullScreenModePrevious = mOptions->fullScreenMode;
|
||||
mOptions->windowSizePrevious = mOptions->windowSize;
|
||||
mOptions->languagePrevious = mOptions->language;
|
||||
break;
|
||||
case 2: // HOW TO PLAY
|
||||
case 3: // HOW TO PLAY
|
||||
runInstructions(INSTRUCTIONS_MODE_MANUAL);
|
||||
break;
|
||||
case 3: // QUIT
|
||||
mPostFade = 1;
|
||||
case 4: // QUIT
|
||||
mPostFade = 2;
|
||||
mFade->activateFade();
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user