Afegida musica als credits

Els globos ara tenen definida una play_area
Opció de canviar la paleta al text
This commit is contained in:
2024-11-24 19:07:19 +01:00
parent b8d4c8f17c
commit ad221243cb
12 changed files with 141 additions and 24 deletions

View File

@@ -7,7 +7,7 @@
#include "texture.h" // Para Texture
// Constructor
Balloon::Balloon(float x, float y, BalloonType type, BalloonSize size, float vel_x, float speed, Uint16 creation_timer, std::shared_ptr<Texture> texture, const std::vector<std::string> &animation)
Balloon::Balloon(float x, float y, BalloonType type, BalloonSize size, float vel_x, float speed, Uint16 creation_timer, SDL_Rect play_area, std::shared_ptr<Texture> texture, const std::vector<std::string> &animation)
: sprite_(std::make_unique<AnimatedSprite>(texture, animation)),
x_(x),
y_(y),
@@ -19,7 +19,8 @@ Balloon::Balloon(float x, float y, BalloonType type, BalloonSize size, float vel
creation_counter_ini_(creation_timer),
type_(type),
size_(size),
speed_(speed)
speed_(speed),
play_area_(play_area)
{
switch (type_)
{
@@ -91,8 +92,8 @@ Balloon::Balloon(float x, float y, BalloonType type, BalloonSize size, float vel
void Balloon::alignTo(int x)
{
x_ = static_cast<float>(x - (w_ / 2));
const int min_x = param.game.play_area.rect.x;
const int max_x = param.game.play_area.rect.w - w_;
const int min_x = play_area_.x;
const int max_x = play_area_.w - w_;
x_ = std::clamp(x_, static_cast<float>(min_x), static_cast<float>(max_x));
}
@@ -149,8 +150,8 @@ void Balloon::move()
// Colisión en las partes laterales de la zona de juego
const int clip = 2;
const float min_x = param.game.play_area.rect.x - clip;
const float max_x = param.game.play_area.rect.w - w_ + clip;
const float min_x = play_area_.x - clip;
const float max_x = play_area_.w - w_ + clip;
if (x_ < min_x || x_ > max_x)
{
x_ = std::clamp(x_, min_x, max_x);
@@ -172,7 +173,7 @@ void Balloon::move()
// Colisión en la parte superior de la zona de juego excepto para la PowerBall
if (type_ != BalloonType::POWERBALL)
{
const int min_y = param.game.play_area.rect.y;
const int min_y = play_area_.y;
if (y_ < min_y)
{
y_ = min_y;
@@ -182,7 +183,7 @@ void Balloon::move()
}
// Colisión en la parte inferior de la zona de juego
const int max_y = param.game.play_area.rect.h - h_;
const int max_y = play_area_.h - h_;
if (y_ > max_y)
{
y_ = max_y;
@@ -254,8 +255,8 @@ void Balloon::updateState()
x_ += vx_;
// Comprueba no se salga por los laterales
const int min_x = param.game.play_area.rect.x;
const int max_x = param.game.play_area.rect.w - w_;
const int min_x = play_area_.x;
const int max_x = play_area_.w - w_;
if (x_ < min_x || x_ > max_x)
{