Continuem treballant en els credits
This commit is contained in:
@@ -171,7 +171,19 @@ void Balloon::move()
|
||||
y_ += vy_ * speed_;
|
||||
|
||||
// Colisión en la parte superior de la zona de juego excepto para la PowerBall
|
||||
if (type_ != BalloonType::POWERBALL)
|
||||
/*if (type_ != BalloonType::POWERBALL)
|
||||
{
|
||||
const int min_y = play_area_.y;
|
||||
if (y_ < min_y)
|
||||
{
|
||||
y_ = min_y;
|
||||
vy_ = -vy_;
|
||||
enableBounce();
|
||||
}
|
||||
}*/
|
||||
|
||||
// Colisión en la parte superior solo si el globo va de subida
|
||||
if (vy_ < 0)
|
||||
{
|
||||
const int min_y = play_area_.y;
|
||||
if (y_ < min_y)
|
||||
|
||||
@@ -38,7 +38,6 @@ struct BalloonFormationUnit
|
||||
BalloonFormationUnit() : number_of_balloons(0), init() {}
|
||||
};
|
||||
|
||||
|
||||
using BalloonFormationPool = std::vector<const BalloonFormationUnit *>;
|
||||
|
||||
class BalloonFormations
|
||||
@@ -67,4 +66,5 @@ public:
|
||||
// Getters
|
||||
const BalloonFormationPool &getPool(int pool) { return balloon_formation_pool_.at(pool); }
|
||||
const BalloonFormationUnit &getSet(int pool, int set) { return *balloon_formation_pool_.at(pool).at(set); }
|
||||
const BalloonFormationUnit &getSet(int set) const { return balloon_formation_.at(set); }
|
||||
};
|
||||
|
||||
@@ -119,9 +119,10 @@ void BalloonManager::deployBalloonFormation(int stage)
|
||||
}
|
||||
}
|
||||
|
||||
void BalloonManager::deployBalloonFormation(int pool, int set_number)
|
||||
// Crea una formación de enemigos específica
|
||||
void BalloonManager::deploySet(int set_number)
|
||||
{
|
||||
const auto set = balloon_formations_->getSet(pool, set_number);
|
||||
const auto set = balloon_formations_->getSet(set_number);
|
||||
const auto numEnemies = set.number_of_balloons;
|
||||
for (int i = 0; i < numEnemies; ++i)
|
||||
{
|
||||
@@ -130,6 +131,18 @@ void BalloonManager::deployBalloonFormation(int pool, int set_number)
|
||||
}
|
||||
}
|
||||
|
||||
// Crea una formación de enemigos específica
|
||||
void BalloonManager::deploySet(int set_number, int y)
|
||||
{
|
||||
const auto set = balloon_formations_->getSet(set_number);
|
||||
const auto numEnemies = set.number_of_balloons;
|
||||
for (int i = 0; i < numEnemies; ++i)
|
||||
{
|
||||
auto p = set.init[i];
|
||||
createBalloon(p.x, y, p.type, p.size, p.vel_x, balloon_speed_, p.creation_counter);
|
||||
}
|
||||
}
|
||||
|
||||
// Vacia del vector de globos los globos que ya no sirven
|
||||
void BalloonManager::freeBalloons()
|
||||
{
|
||||
@@ -350,7 +363,7 @@ void BalloonManager::reLoad()
|
||||
// Crea dos globos gordos
|
||||
void BalloonManager::createTwoBigBalloons()
|
||||
{
|
||||
deployBalloonFormation(0, 1);
|
||||
deploySet(1);
|
||||
}
|
||||
|
||||
// Obtiene el nivel de ameza actual generado por los globos
|
||||
|
||||
@@ -53,9 +53,12 @@ public:
|
||||
// Vacia del vector de globos los globos que ya no sirven
|
||||
void freeBalloons();
|
||||
|
||||
// Crea una formación de enemigos
|
||||
// Crea una formación de enemigos al azar
|
||||
void deployBalloonFormation(int stage);
|
||||
void deployBalloonFormation(int pool, int set);
|
||||
|
||||
// Crea una formación de enemigos específica
|
||||
void deploySet(int set);
|
||||
void deploySet(int set, int y);
|
||||
|
||||
// Actualiza la variable enemyDeployCounter
|
||||
void updateBalloonDeployCounter();
|
||||
|
||||
@@ -28,11 +28,10 @@ Credits::Credits()
|
||||
tiled_bg_(std::make_unique<TiledBG>(param.game.game_area.rect, TiledBGMode::DIAGONAL))
|
||||
{
|
||||
section::name = section::Name::CREDITS;
|
||||
balloon_manager_->setPlayArea(param.game.game_area.rect);
|
||||
balloon_manager_->createTwoBigBalloons();
|
||||
balloon_manager_->deployBalloonFormation(4,2);
|
||||
balloon_manager_->deployBalloonFormation(4,5);
|
||||
balloon_manager_->createPowerBall();
|
||||
// balloon_manager_->setPlayArea(param.game.game_area.rect);
|
||||
const auto r = param.game.game_area.rect;
|
||||
const int bars = 30;
|
||||
balloon_manager_->setPlayArea({r.x, r.y + bars, r.w, r.h - bars});
|
||||
SDL_SetTextureBlendMode(text_texture_, SDL_BLENDMODE_BLEND);
|
||||
fillTextTexture();
|
||||
JA_PlayMusic(Resource::get()->getMusic("credits.ogg"));
|
||||
@@ -67,6 +66,7 @@ void Credits::update()
|
||||
tiled_bg_->update();
|
||||
balloon_manager_->update();
|
||||
updateRects();
|
||||
throwBalloons();
|
||||
Screen::get()->update();
|
||||
++counter_;
|
||||
}
|
||||
@@ -83,6 +83,11 @@ void Credits::render()
|
||||
|
||||
tiled_bg_->render();
|
||||
balloon_manager_->render();
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0, 0, 0, 255);
|
||||
SDL_Rect r1 = {0, 0, 320, 30};
|
||||
SDL_Rect r2 = {0, 255 - 30, 320, 30};
|
||||
SDL_RenderFillRect(Screen::get()->getRenderer(), &r1);
|
||||
SDL_RenderFillRect(Screen::get()->getRenderer(), &r2);
|
||||
SDL_RenderCopy(Screen::get()->getRenderer(), text_texture_, &credits_rect_src_, &credits_rect_dst_);
|
||||
SDL_RenderCopy(Screen::get()->getRenderer(), text_texture_, &mini_logo_rect_src_, &mini_logo_rect_dst_);
|
||||
|
||||
@@ -221,3 +226,24 @@ void Credits::updateRects()
|
||||
}
|
||||
mini_logo_rect_dst_.y = std::max(mini_logo_rect_dst_.y, mini_logo_final_pos_);
|
||||
}
|
||||
|
||||
// Tira globos al escenario
|
||||
void Credits::throwBalloons()
|
||||
{
|
||||
constexpr int speed = 200;
|
||||
const std::vector<int> sets = {0, 63, 25, 67, 17, 75, 13, 50};
|
||||
|
||||
if (counter_ > ((sets.size() - 1) * speed) * 3)
|
||||
return;
|
||||
|
||||
if (counter_ % speed == 0)
|
||||
{
|
||||
const int index = (counter_ / speed) % sets.size();
|
||||
balloon_manager_->deploySet(sets.at(index), -50);
|
||||
}
|
||||
|
||||
if (counter_ % (speed * 4) == 0)
|
||||
{
|
||||
balloon_manager_->createPowerBall();
|
||||
}
|
||||
}
|
||||
@@ -42,6 +42,9 @@ private:
|
||||
// Actualiza el destino de los rectangulos de las texturas
|
||||
void updateRects();
|
||||
|
||||
// Tira globos al escenario
|
||||
void throwBalloons();
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Credits();
|
||||
|
||||
Reference in New Issue
Block a user