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