Nous grafics per a la powerball
Nou comportament per a la powerball
This commit is contained in:
@@ -56,7 +56,7 @@ Balloon::Balloon(float x, float y, BalloonType type, BalloonSize size, float vel
|
||||
case BalloonType::POWERBALL:
|
||||
{
|
||||
const int index = 3;
|
||||
h_ = w_ = BALLOON_SIZE[index];
|
||||
h_ = w_ = BALLOON_SIZE[4];
|
||||
power_ = score_ = menace_ = 0;
|
||||
|
||||
vy_ = 0;
|
||||
@@ -100,32 +100,42 @@ void Balloon::alignTo(int x)
|
||||
// Pinta el globo en la pantalla
|
||||
void Balloon::render()
|
||||
{
|
||||
if (isBeingCreated())
|
||||
if (type_ == BalloonType::POWERBALL)
|
||||
{
|
||||
// Aplica alpha blending
|
||||
sprite_->getTexture()->setAlpha(255 - (int)((float)creation_counter_ * (255.0f / (float)creation_counter_ini_)));
|
||||
// Renderizado para la PowerBall
|
||||
SDL_Point p = {24, 24};
|
||||
sprite_->setRotatingCenter(&p);
|
||||
sprite_->render();
|
||||
sprite_->getTexture()->setAlpha(255);
|
||||
// Añade la máscara del borde y los reflejos
|
||||
auto sp = std::make_unique<Sprite>(sprite_->getTexture(), sprite_->getPosition());
|
||||
sp->setSpriteClip(BALLOON_SIZE[4], 0, BALLOON_SIZE[4], BALLOON_SIZE[4]);
|
||||
sp->render();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bouncing_.enabled)
|
||||
// Renderizado para el resto de globos
|
||||
if (isBeingCreated())
|
||||
{
|
||||
// Aplica efecto de bouncing
|
||||
sprite_->setPos(x_ + bouncing_.despX, y_ + bouncing_.despY);
|
||||
// Renderizado con transparencia
|
||||
sprite_->getTexture()->setAlpha(255 - (int)((float)creation_counter_ * (255.0f / (float)creation_counter_ini_)));
|
||||
sprite_->render();
|
||||
sprite_->setPos(x_ - bouncing_.despX, y_ - bouncing_.despY);
|
||||
sprite_->getTexture()->setAlpha(255);
|
||||
}
|
||||
else
|
||||
sprite_->render();
|
||||
}
|
||||
|
||||
// Añade la máscara del borde a la PowerBall
|
||||
if (type_ == BalloonType::POWERBALL && !isBeingCreated())
|
||||
{
|
||||
auto sp = std::make_unique<Sprite>(sprite_->getTexture(), sprite_->getPosition());
|
||||
sp->setSpriteClip(BALLOON_SIZE[3], 0, BALLOON_SIZE[3], BALLOON_SIZE[3]);
|
||||
sp->render();
|
||||
{
|
||||
if (bouncing_.enabled)
|
||||
{
|
||||
// Renderizado con efecto de bouncing
|
||||
sprite_->setPos(x_ + bouncing_.despX, y_ + bouncing_.despY);
|
||||
sprite_->render();
|
||||
// sprite_->setPos(x_ - bouncing_.despX, y_ - bouncing_.despY);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Renderizado normal
|
||||
sprite_->render();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,22 +158,28 @@ void Balloon::move()
|
||||
vx_ = -vx_;
|
||||
// Activa el efecto de rebote o invierte la rotación
|
||||
if (type_ == BalloonType::POWERBALL)
|
||||
{
|
||||
sprite_->switchRotate();
|
||||
}
|
||||
else
|
||||
{
|
||||
enableBounce();
|
||||
}
|
||||
}
|
||||
|
||||
// Mueve el globo en vertical
|
||||
y_ += vy_ * speed_;
|
||||
|
||||
// Colisión en la parte superior de la zona de juego
|
||||
const int min_y = param.game.play_area.rect.y;
|
||||
if (y_ < min_y)
|
||||
// Colisión en la parte superior de la zona de juego excepto para la PowerBall
|
||||
if (type_ != BalloonType::POWERBALL)
|
||||
{
|
||||
y_ = min_y;
|
||||
vy_ = -vy_;
|
||||
if (type_ != BalloonType::POWERBALL)
|
||||
const int min_y = param.game.play_area.rect.y;
|
||||
if (y_ < min_y)
|
||||
{
|
||||
y_ = min_y;
|
||||
vy_ = -vy_;
|
||||
enableBounce();
|
||||
}
|
||||
}
|
||||
|
||||
// Colisión en la parte inferior de la zona de juego
|
||||
@@ -173,7 +189,9 @@ void Balloon::move()
|
||||
y_ = max_y;
|
||||
vy_ = -default_vy_;
|
||||
if (type_ != BalloonType::POWERBALL)
|
||||
{
|
||||
enableBounce();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user