modificada la classe balloon: eliminat el estat popping i dibuixat desde fitxers gif, pero no funciona el canvi de paleta
This commit is contained in:
158
source/game.cpp
158
source/game.cpp
@@ -360,6 +360,9 @@ void Game::loadMedia()
|
||||
balloon4Texture->addPalette(asset->get("balloon_green_pal.gif"));
|
||||
balloonTextures.push_back(balloon4Texture);
|
||||
|
||||
Texture *balloon5Texture = new Texture(renderer, asset->get("powerball.png"));
|
||||
balloonTextures.push_back(balloon5Texture);
|
||||
|
||||
// Texturas - Explosiones
|
||||
Texture *explosion1Texture = new Texture(renderer, asset->get("balloon1_explosion.png"));
|
||||
explosionsTextures.push_back(explosion1Texture);
|
||||
@@ -417,30 +420,38 @@ void Game::loadMedia()
|
||||
playerTextures.push_back(player2Textures);
|
||||
|
||||
// Animaciones -- Jugador
|
||||
std::vector<std::string> *playerAnimation = new std::vector<std::string>;
|
||||
loadAnimations(asset->get("player.ani"), playerAnimation);
|
||||
playerAnimations.push_back(playerAnimation);
|
||||
{
|
||||
std::vector<std::string> *playerAnimation = new std::vector<std::string>;
|
||||
loadAnimations(asset->get("player.ani"), playerAnimation);
|
||||
playerAnimations.push_back(playerAnimation);
|
||||
|
||||
std::vector<std::string> *playerPowerAnimation = new std::vector<std::string>;
|
||||
loadAnimations(asset->get("player_power.ani"), playerPowerAnimation);
|
||||
playerAnimations.push_back(playerPowerAnimation);
|
||||
std::vector<std::string> *playerPowerAnimation = new std::vector<std::string>;
|
||||
loadAnimations(asset->get("player_power.ani"), playerPowerAnimation);
|
||||
playerAnimations.push_back(playerPowerAnimation);
|
||||
}
|
||||
|
||||
// Animaciones -- Globos
|
||||
std::vector<std::string> *balloon1Animation = new std::vector<std::string>;
|
||||
loadAnimations(asset->get("balloon1.ani"), balloon1Animation);
|
||||
balloonAnimations.push_back(balloon1Animation);
|
||||
{
|
||||
std::vector<std::string> *balloon1Animation = new std::vector<std::string>;
|
||||
loadAnimations(asset->get("balloon1.ani"), balloon1Animation);
|
||||
balloonAnimations.push_back(balloon1Animation);
|
||||
|
||||
std::vector<std::string> *balloon2Animation = new std::vector<std::string>;
|
||||
loadAnimations(asset->get("balloon2.ani"), balloon2Animation);
|
||||
balloonAnimations.push_back(balloon2Animation);
|
||||
std::vector<std::string> *balloon2Animation = new std::vector<std::string>;
|
||||
loadAnimations(asset->get("balloon2.ani"), balloon2Animation);
|
||||
balloonAnimations.push_back(balloon2Animation);
|
||||
|
||||
std::vector<std::string> *balloon3Animation = new std::vector<std::string>;
|
||||
loadAnimations(asset->get("balloon3.ani"), balloon3Animation);
|
||||
balloonAnimations.push_back(balloon3Animation);
|
||||
std::vector<std::string> *balloon3Animation = new std::vector<std::string>;
|
||||
loadAnimations(asset->get("balloon3.ani"), balloon3Animation);
|
||||
balloonAnimations.push_back(balloon3Animation);
|
||||
|
||||
std::vector<std::string> *balloon4Animation = new std::vector<std::string>;
|
||||
loadAnimations(asset->get("balloon4.ani"), balloon4Animation);
|
||||
balloonAnimations.push_back(balloon4Animation);
|
||||
std::vector<std::string> *balloon4Animation = new std::vector<std::string>;
|
||||
loadAnimations(asset->get("balloon4.ani"), balloon4Animation);
|
||||
balloonAnimations.push_back(balloon4Animation);
|
||||
|
||||
std::vector<std::string> *balloon5Animation = new std::vector<std::string>;
|
||||
loadAnimations(asset->get("powerball.ani"), balloon5Animation);
|
||||
balloonAnimations.push_back(balloon5Animation);
|
||||
}
|
||||
|
||||
// Animaciones -- Explosiones
|
||||
std::vector<std::string> *explosions1Animation = new std::vector<std::string>;
|
||||
@@ -1805,7 +1816,7 @@ void Game::createPowerBall()
|
||||
const int x[3] = {left, center, right};
|
||||
const float vx[3] = {BALLOON_VELX_POSITIVE, BALLOON_VELX_POSITIVE, BALLOON_VELX_NEGATIVE};
|
||||
|
||||
Balloon *b = new Balloon(x[luck], posY, POWER_BALL, vx[luck], enemySpeed, 100, balloonTextures[3], balloonAnimations[3], renderer);
|
||||
Balloon *b = new Balloon(x[luck], posY, POWER_BALL, vx[luck], enemySpeed, 100, balloonTextures[4], balloonAnimations[4], renderer);
|
||||
balloons.push_back(b);
|
||||
|
||||
powerBallEnabled = true;
|
||||
@@ -1929,51 +1940,48 @@ void Game::popBalloon(Balloon *balloon)
|
||||
balloonsPopped++;
|
||||
|
||||
const int kind = balloon->getKind();
|
||||
switch (kind)
|
||||
if (kind == POWER_BALL)
|
||||
{
|
||||
// Si es del tipo más pequeño, simplemente elimina el globo
|
||||
case BALLOON_1:
|
||||
balloon->pop();
|
||||
break;
|
||||
|
||||
case HEXAGON_1:
|
||||
balloon->pop();
|
||||
break;
|
||||
|
||||
// Si es del tipo PowerBall, destruye todos los globos
|
||||
case POWER_BALL:
|
||||
destroyAllBalloons();
|
||||
powerBallEnabled = false;
|
||||
enemyDeployCounter = 20;
|
||||
break;
|
||||
|
||||
// En cualquier otro caso, crea dos globos de un tipo inferior
|
||||
default:
|
||||
const int index = createBalloon(0, balloon->getPosY(), balloon->getKind() - 1, BALLOON_VELX_NEGATIVE, enemySpeed, 0);
|
||||
balloons[index]->allignTo(balloon->getPosX() + (balloon->getWidth() / 2));
|
||||
if (balloons[index]->getClass() == BALLOON_CLASS)
|
||||
{
|
||||
balloons[index]->setVelY(-2.50f);
|
||||
}
|
||||
else
|
||||
{
|
||||
const int size = balloon->getSize();
|
||||
if (size == BALLOON_SIZE_1)
|
||||
{ // Si es del tipo más pequeño, simplemente elimina el globo
|
||||
explosions->add(balloon->getPosX(), balloon->getPosY(), size);
|
||||
balloon->pop();
|
||||
}
|
||||
else
|
||||
{
|
||||
balloons[index]->setVelY(BALLOON_VELX_NEGATIVE);
|
||||
}
|
||||
{ // En cualquier otro caso, crea dos globos de un tipo inferior
|
||||
const int index = createBalloon(0, balloon->getPosY(), balloon->getKind() - 1, BALLOON_VELX_NEGATIVE, enemySpeed, 0);
|
||||
balloons[index]->allignTo(balloon->getPosX() + (balloon->getWidth() / 2));
|
||||
if (balloons[index]->getClass() == BALLOON_CLASS)
|
||||
{
|
||||
balloons[index]->setVelY(-2.50f);
|
||||
}
|
||||
else
|
||||
{
|
||||
balloons[index]->setVelY(BALLOON_VELX_NEGATIVE);
|
||||
}
|
||||
|
||||
const int index2 = createBalloon(0, balloon->getPosY(), balloon->getKind() - 1, BALLOON_VELX_POSITIVE, enemySpeed, 0);
|
||||
balloons[index2]->allignTo(balloon->getPosX() + (balloon->getWidth() / 2));
|
||||
if (balloons[index2]->getClass() == BALLOON_CLASS)
|
||||
{
|
||||
balloons[index2]->setVelY(-2.50f);
|
||||
}
|
||||
else
|
||||
{
|
||||
balloons[index2]->setVelY(BALLOON_VELX_NEGATIVE);
|
||||
}
|
||||
const int index2 = createBalloon(0, balloon->getPosY(), balloon->getKind() - 1, BALLOON_VELX_POSITIVE, enemySpeed, 0);
|
||||
balloons[index2]->allignTo(balloon->getPosX() + (balloon->getWidth() / 2));
|
||||
if (balloons[index2]->getClass() == BALLOON_CLASS)
|
||||
{
|
||||
balloons[index2]->setVelY(-2.50f);
|
||||
}
|
||||
else
|
||||
{
|
||||
balloons[index2]->setVelY(BALLOON_VELX_NEGATIVE);
|
||||
}
|
||||
|
||||
// Elimina el globo
|
||||
balloon->pop();
|
||||
break;
|
||||
// Elimina el globo
|
||||
explosions->add(balloon->getPosX(), balloon->getPosY(), size);
|
||||
balloon->pop();
|
||||
}
|
||||
}
|
||||
|
||||
// Recalcula el nivel de amenaza
|
||||
@@ -1986,7 +1994,8 @@ void Game::destroyBalloon(Balloon *balloon)
|
||||
int score = 0;
|
||||
|
||||
// Calcula la puntuación y el poder que generaria el globo en caso de romperlo a él y a sus hijos
|
||||
switch (balloon->getSize())
|
||||
const int size = balloon->getSize();
|
||||
switch (size)
|
||||
{
|
||||
case BALLOON_SIZE_4:
|
||||
score = BALLOON_SCORE_4 + (2 * BALLOON_SCORE_3) + (4 * BALLOON_SCORE_2) + (8 * BALLOON_SCORE_1);
|
||||
@@ -2022,6 +2031,7 @@ void Game::destroyBalloon(Balloon *balloon)
|
||||
balloonsPopped += power;
|
||||
|
||||
// Destruye el globo
|
||||
explosions->add(balloon->getPosX(), balloon->getPosY(), size);
|
||||
balloon->pop();
|
||||
|
||||
// Recalcula el nivel de amenaza
|
||||
@@ -2094,10 +2104,7 @@ int Game::countBalloons()
|
||||
{
|
||||
if (balloon->isEnabled())
|
||||
{
|
||||
if (!balloon->isPopping())
|
||||
{
|
||||
num++;
|
||||
}
|
||||
num++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2223,18 +2230,8 @@ void Game::checkBulletBalloonCollision()
|
||||
players[index]->addScore(Uint32(balloon->getScore() * players[index]->getScoreMultiplier() * difficultyScoreMultiplier));
|
||||
updateHiScore();
|
||||
|
||||
// Explota el globo
|
||||
popBalloon(balloon);
|
||||
|
||||
// Sonido de explosión
|
||||
JA_PlaySound(balloonSound);
|
||||
|
||||
// Deshabilita la bala
|
||||
bullet->disable();
|
||||
|
||||
// Suelta el item en caso de que salga uno
|
||||
// Suelta el item si se da el caso
|
||||
const int droppeditem = dropItem();
|
||||
// if ((droppeditem != NO_KIND) && !(demo.enabled) && !(demo.recording))
|
||||
if ((droppeditem != NO_KIND) && !(demo.recording))
|
||||
{
|
||||
if (droppeditem != ITEM_COFFEE_MACHINE)
|
||||
@@ -2249,6 +2246,15 @@ void Game::checkBulletBalloonCollision()
|
||||
}
|
||||
}
|
||||
|
||||
// Explota el globo
|
||||
popBalloon(balloon);
|
||||
|
||||
// Sonido de explosión
|
||||
JA_PlaySound(balloonSound);
|
||||
|
||||
// Deshabilita la bala
|
||||
bullet->disable();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2726,6 +2732,9 @@ void Game::update()
|
||||
freeBalloons();
|
||||
freeItems();
|
||||
freeSmartSprites();
|
||||
|
||||
// Dibuja los graficos de la zona de juego en la textura
|
||||
fillCanvas();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2793,9 +2802,6 @@ void Game::fillCanvas()
|
||||
// Dibuja el juego
|
||||
void Game::render()
|
||||
{
|
||||
// Dibuja los graficos de la zona de juego en la textura
|
||||
fillCanvas();
|
||||
|
||||
// Prepara para empezar a dibujar en la textura de juego
|
||||
screen->start();
|
||||
|
||||
@@ -2833,7 +2839,7 @@ void Game::updateMenace()
|
||||
if (menaceCurrent < menaceThreshold)
|
||||
{
|
||||
// Crea una formación de enemigos
|
||||
// deployEnemyFormation();
|
||||
deployEnemyFormation();
|
||||
|
||||
// Recalcula el nivel de amenaza con el nuevo globo
|
||||
evaluateAndSetMenace();
|
||||
|
||||
Reference in New Issue
Block a user