Continuem treballant en els credits
This commit is contained in:
@@ -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_);
|
||||
|
||||
@@ -220,4 +225,25 @@ void Credits::updateRects()
|
||||
--mini_logo_rect_dst_.y;
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user