Nous grafics per a la powerball
Nou comportament per a la powerball
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.5 KiB |
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -15,7 +15,7 @@ constexpr int MAX_BOUNCE = 10;
|
||||
constexpr int BALLOON_SCORE[] = {50, 100, 200, 400};
|
||||
constexpr int BALLOON_POWER[] = {1, 3, 7, 15};
|
||||
constexpr int BALLOON_MENACE[] = {1, 2, 4, 8};
|
||||
constexpr int BALLOON_SIZE[] = {10, 16, 26, 46};
|
||||
constexpr int BALLOON_SIZE[] = {10, 16, 26, 48, 49};
|
||||
|
||||
// Tamaños de globo
|
||||
enum class BalloonSize : Uint8
|
||||
|
||||
@@ -88,7 +88,7 @@ void BalloonManager::deployBalloonFormation(int stage)
|
||||
createPowerBall();
|
||||
|
||||
// Da un poco de margen para que se creen mas enemigos
|
||||
balloon_deploy_counter_ = 300;
|
||||
balloon_deploy_counter_ = 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -171,13 +171,13 @@ void BalloonManager::createChildBalloon(const std::shared_ptr<Balloon> &balloon,
|
||||
// Crea una PowerBall
|
||||
void BalloonManager::createPowerBall()
|
||||
{
|
||||
constexpr auto values = 6;
|
||||
constexpr auto pos_y = -BLOCK;
|
||||
constexpr int creation_time = 300;
|
||||
constexpr int values = 6;
|
||||
constexpr int pos_y = -BALLOON_SIZE[4];
|
||||
constexpr int creation_time = 0;
|
||||
|
||||
const auto left = param.game.play_area.rect.x;
|
||||
const auto center = param.game.play_area.center_x - (BALLOON_SIZE[3] / 2);
|
||||
const auto right = param.game.play_area.rect.w - BALLOON_SIZE[3];
|
||||
const auto center = param.game.play_area.center_x - (BALLOON_SIZE[4] / 2);
|
||||
const auto right = param.game.play_area.rect.w - BALLOON_SIZE[4];
|
||||
|
||||
const auto luck = rand() % values;
|
||||
const int x[values] = {left, left, center, center, right, right};
|
||||
|
||||
@@ -96,6 +96,12 @@ void MovingSprite::setAngle(double value)
|
||||
rotate_.angle = value;
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void MovingSprite::setRotatingCenter(SDL_Point *point)
|
||||
{
|
||||
rotate_.center = point;
|
||||
}
|
||||
|
||||
// Incrementa el valor del ángulo
|
||||
void MovingSprite::updateAngle()
|
||||
{
|
||||
@@ -172,41 +178,6 @@ SDL_RendererFlip MovingSprite::getFlip()
|
||||
return flip_;
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
float MovingSprite::getPosX() const
|
||||
{
|
||||
return x_;
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
float MovingSprite::getPosY() const
|
||||
{
|
||||
return y_;
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
float MovingSprite::getVelX() const
|
||||
{
|
||||
return vx_;
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
float MovingSprite::getVelY() const
|
||||
{
|
||||
return vy_;
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
float MovingSprite::getAccelX() const
|
||||
{
|
||||
return ax_;
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
float MovingSprite::getAccelY() const
|
||||
{
|
||||
return ay_;
|
||||
}
|
||||
|
||||
// Establece la posición y_ el tamaño del objeto
|
||||
void MovingSprite::setPos(SDL_Rect rect)
|
||||
|
||||
@@ -65,12 +65,12 @@ public:
|
||||
void render() override;
|
||||
|
||||
// Obtiene la variable
|
||||
float getPosX() const;
|
||||
float getPosY() const;
|
||||
float getVelX() const;
|
||||
float getVelY() const;
|
||||
float getAccelX() const;
|
||||
float getAccelY() const;
|
||||
float getPosX() const { return x_; }
|
||||
float getPosY() const { return y_; }
|
||||
float getVelX() const { return vx_; }
|
||||
float getVelY() const { return vy_; }
|
||||
float getAccelX() const { return ax_; }
|
||||
float getAccelY() const { return ay_; }
|
||||
|
||||
// Establece la variable
|
||||
void setVelX(float value);
|
||||
@@ -87,6 +87,7 @@ public:
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setAngle(double vaue);
|
||||
void setRotatingCenter(SDL_Point *point);
|
||||
|
||||
// Activa o desactiva el efecto derotación
|
||||
void enableRotate();
|
||||
|
||||
Reference in New Issue
Block a user