es pot definir el color dels globos (dels 4 colors disponibles) al fitxer de parametres

This commit is contained in:
2025-07-12 21:16:07 +02:00
parent ccce96c731
commit e882a22b3c
9 changed files with 105 additions and 65 deletions

View File

@@ -43,14 +43,19 @@ title.title_c_c_position 80 # Posición Y del título principal
background.attenuate_color FFFFFF00 # Color de atenuación del fondo (RGBA hexadecimal) background.attenuate_color FFFFFF00 # Color de atenuación del fondo (RGBA hexadecimal)
## --- BALLOONS --- ## --- BALLOONS ---
balloon_1.vel 2.75f # Velocidad inicial del globo 1 balloon.settings[0].vel 2.75f # Velocidad inicial del globo 1
balloon_1.grav 0.09f # Gravedad aplicada al globo 1 balloon.settings[0].grav 0.09f # Gravedad aplicada al globo 1
balloon_2.vel 3.70f # Velocidad inicial del globo 2 balloon.settings[1].vel 3.70f # Velocidad inicial del globo 2
balloon_2.grav 0.10f # Gravedad aplicada al globo 2 balloon.settings[1].grav 0.10f # Gravedad aplicada al globo 2
balloon_3.vel 4.70f # Velocidad inicial del globo 3 balloon.settings[2].vel 4.70f # Velocidad inicial del globo 3
balloon_3.grav 0.10f # Gravedad aplicada al globo 3 balloon.settings[2].grav 0.10f # Gravedad aplicada al globo 3
balloon_4.vel 5.45f # Velocidad inicial del globo 4 balloon.settings[3].vel 5.45f # Velocidad inicial del globo 4
balloon_4.grav 0.10f # Gravedad aplicada al globo 4 balloon.settings[3].grav 0.10f # Gravedad aplicada al globo 4
balloon.color[0] blue # Color de creación del globo normal
balloon.color[1] orange # Color del globo normal
balloon.color[2] red # Color de creación del globo que rebota
balloon.color[3] green # Color del globo que rebota
## --- NOTIFICATION --- ## --- NOTIFICATION ---
notification.pos_v TOP # Posición vertical de la notificación (TOP/BOTTOM) notification.pos_v TOP # Posición vertical de la notificación (TOP/BOTTOM)

View File

@@ -43,14 +43,19 @@ title.title_c_c_position 80 # Posición Y del título principal
background.attenuate_color FFFFFF00 # Color de atenuación del fondo (RGBA hexadecimal) background.attenuate_color FFFFFF00 # Color de atenuación del fondo (RGBA hexadecimal)
## --- BALLOONS --- ## --- BALLOONS ---
balloon_1.vel 2.75f # Velocidad inicial del globo 1 balloon.settings[0].vel 2.75f # Velocidad inicial del globo 1
balloon_1.grav 0.09f # Gravedad aplicada al globo 1 balloon.settings[0].grav 0.09f # Gravedad aplicada al globo 1
balloon_2.vel 3.70f # Velocidad inicial del globo 2 balloon.settings[1].vel 3.70f # Velocidad inicial del globo 2
balloon_2.grav 0.10f # Gravedad aplicada al globo 2 balloon.settings[1].grav 0.10f # Gravedad aplicada al globo 2
balloon_3.vel 4.70f # Velocidad inicial del globo 3 balloon.settings[2].vel 4.70f # Velocidad inicial del globo 3
balloon_3.grav 0.10f # Gravedad aplicada al globo 3 balloon.settings[2].grav 0.10f # Gravedad aplicada al globo 3
balloon_4.vel 5.45f # Velocidad inicial del globo 4 balloon.settings[3].vel 5.45f # Velocidad inicial del globo 4
balloon_4.grav 0.10f # Gravedad aplicada al globo 4 balloon.settings[3].grav 0.10f # Gravedad aplicada al globo 4
balloon.color[0] blue # Color de creación del globo normal
balloon.color[1] orange # Color del globo normal
balloon.color[2] red # Color de creación del globo que rebota
balloon.color[3] green # Color del globo que rebota
## --- NOTIFICATION --- ## --- NOTIFICATION ---
notification.pos_v TOP # Posición vertical de la notificación (TOP/BOTTOM) notification.pos_v TOP # Posición vertical de la notificación (TOP/BOTTOM)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -32,8 +32,8 @@ Balloon::Balloon(float x, float y, BalloonType type, BalloonSize size, float vel
max_vy_ = 3.0f; max_vy_ = 3.0f;
const int index = static_cast<int>(size_); const int index = static_cast<int>(size_);
gravity_ = param.balloon.at(index).grav; gravity_ = param.balloon.settings.at(index).grav;
default_vy_ = param.balloon.at(index).vel; default_vy_ = param.balloon.settings.at(index).vel;
h_ = w_ = BALLOON_SIZE[index]; h_ = w_ = BALLOON_SIZE[index];
power_ = BALLOON_POWER[index]; power_ = BALLOON_POWER[index];
menace_ = BALLOON_MENACE[index]; menace_ = BALLOON_MENACE[index];
@@ -67,8 +67,8 @@ Balloon::Balloon(float x, float y, BalloonType type, BalloonSize size, float vel
vy_ = 0; vy_ = 0;
max_vy_ = 3.0f; max_vy_ = 3.0f;
gravity_ = param.balloon.at(index).grav; gravity_ = param.balloon.settings.at(index).grav;
default_vy_ = param.balloon.at(index).vel; default_vy_ = param.balloon.settings.at(index).vel;
sprite_->setRotate(creation_timer <= 0); sprite_->setRotate(creation_timer <= 0);
sprite_->setRotateAmount(vx_ > 0.0f ? 2.0 : -2.0); sprite_->setRotateAmount(vx_ > 0.0f ? 2.0 : -2.0);
@@ -301,12 +301,12 @@ void Balloon::setAnimation()
normal_animation = "powerball"; normal_animation = "powerball";
break; break;
case BalloonType::FLOATER: case BalloonType::FLOATER:
creating_animation = "red"; creating_animation = param.balloon.color.at(2);
normal_animation = "green"; normal_animation = param.balloon.color.at(3);
break; break;
default: default:
creating_animation = "blue"; creating_animation = param.balloon.color.at(0);
normal_animation = "orange"; normal_animation = param.balloon.color.at(1);
break; break;
} }

View File

@@ -58,10 +58,15 @@ void initParam()
param.background.attenuate_color = Color(255, 255, 255, 0); param.background.attenuate_color = Color(255, 255, 255, 0);
// BALLOONS // BALLOONS
param.balloon.emplace_back(0.09f, 2.60f); param.balloon.settings.at(0) = ParamBalloon::Settings(0.09f, 2.60f);
param.balloon.emplace_back(0.10f, 3.50f); param.balloon.settings.at(1) = ParamBalloon::Settings(0.10f, 3.50f);
param.balloon.emplace_back(0.10f, 4.50f); param.balloon.settings.at(2) = ParamBalloon::Settings(0.10f, 4.50f);
param.balloon.emplace_back(0.10f, 4.95f); param.balloon.settings.at(3) = ParamBalloon::Settings(0.10f, 4.95f);
param.balloon.color.at(0) = "blue";
param.balloon.color.at(1) = "orange";
param.balloon.color.at(2) = "red";
param.balloon.color.at(3) = "green";
// NOTIFICATION // NOTIFICATION
param.notification.pos_v = NotifyPosition::TOP; param.notification.pos_v = NotifyPosition::TOP;
@@ -296,44 +301,64 @@ bool setParams(const std::string &var, const std::string &value)
} }
// BALLOON // BALLOON
else if (var == "balloon_1.vel") else if (var == "balloon.settings[0].vel")
{ {
param.balloon.at(0).vel = std::stof(value); param.balloon.settings.at(0).vel = std::stof(value);
} }
else if (var == "balloon_1.grav") else if (var == "balloon.settings[0].grav")
{ {
param.balloon.at(0).grav = std::stof(value); param.balloon.settings.at(0).grav = std::stof(value);
} }
else if (var == "balloon_2.vel") else if (var == "balloon.settings[1].vel")
{ {
param.balloon.at(1).vel = std::stof(value); param.balloon.settings.at(1).vel = std::stof(value);
} }
else if (var == "balloon_2.grav") else if (var == "balloon.settings[1].grav")
{ {
param.balloon.at(1).grav = std::stof(value); param.balloon.settings.at(1).grav = std::stof(value);
} }
else if (var == "balloon_3.vel") else if (var == "balloon.settings[2].vel")
{ {
param.balloon.at(2).vel = std::stof(value); param.balloon.settings.at(2).vel = std::stof(value);
} }
else if (var == "balloon_3.grav") else if (var == "balloon.settings[2].grav")
{ {
param.balloon.at(2).grav = std::stof(value); param.balloon.settings.at(2).grav = std::stof(value);
} }
else if (var == "balloon_4.vel") else if (var == "balloon.settings[3].vel")
{ {
param.balloon.at(3).vel = std::stof(value); param.balloon.settings.at(3).vel = std::stof(value);
} }
else if (var == "balloon_4.grav") else if (var == "balloon.settings[3].grav")
{ {
param.balloon.at(3).grav = std::stof(value); param.balloon.settings.at(3).grav = std::stof(value);
}
else if (var == "balloon.color[0]")
{
param.balloon.color.at(0) = value;
}
else if (var == "balloon.color[1]")
{
param.balloon.color.at(1) = value;
}
else if (var == "balloon.color[2]")
{
param.balloon.color.at(2) = value;
}
else if (var == "balloon.color[3]")
{
param.balloon.color.at(3) = value;
} }
// NOTIFICACIONES // NOTIFICACIONES

View File

@@ -46,15 +46,21 @@ struct ParamBackground
Color attenuate_color; // Color para atenuar el fondo Color attenuate_color; // Color para atenuar el fondo
}; };
// --- Parámetros de los globos (balloons) --- // --- Parámetros de los globos ---
struct ParamBalloon struct ParamBalloon
{ {
float grav; // Aceleración en el eje Y. Modifica la velocidad struct Settings
float vel; // Velocidad inicial al rebotar contra el suelo {
float grav; // Aceleración en el eje Y. Modifica la velocidad
float vel; // Velocidad inicial al rebotar contra el suelo
// Constructor // Constructor
explicit ParamBalloon(float grav_val = 0.0f, float vel_val = 0.0f) explicit Settings(float grav_val = 0.0f, float vel_val = 0.0f)
: grav(grav_val), vel(vel_val) {} : grav(grav_val), vel(vel_val) {}
};
std::array<Settings, 4> settings;
std::array<std::string, 4> color;
}; };
// --- Parámetros de las notificaciones --- // --- Parámetros de las notificaciones ---
@@ -113,23 +119,22 @@ struct ParamResource
// --- Estructura principal para almacenar todos los parámetros del juego --- // --- Estructura principal para almacenar todos los parámetros del juego ---
struct Param struct Param
{ {
ParamGame game; // Parámetros del juego ParamGame game; // Parámetros del juego
ParamFade fade; // Parámetros del fade ParamFade fade; // Parámetros del fade
ParamScoreboard scoreboard; // Rectángulo del marcador ParamScoreboard scoreboard; // Rectángulo del marcador
ParamTitle title; // Parámetros de la pantalla de título ParamTitle title; // Parámetros de la pantalla de título
ParamBackground background; // Parámetros del fondo ParamBackground background; // Parámetros del fondo
std::vector<ParamBalloon> balloon; // Parámetros de los globos ParamBalloon balloon; // Parámetros de los globos
ParamNotification notification; // Parámetros de las notificaciones ParamNotification notification; // Parámetros de las notificaciones
ParamServiceMenu service_menu; // Parámetros del menú de servicio ParamServiceMenu service_menu; // Parámetros del menú de servicio
ParamIntro intro; // Parámetros de la intro ParamIntro intro; // Parámetros de la intro
ParamDebug debug; // Parámetros para Debug ParamDebug debug; // Parámetros para Debug
ParamResource resource; // Parámetros para Resource ParamResource resource; // Parámetros para Resource
// Constructor // Constructor
Param() : game(), fade(), scoreboard(), title(), background(), notification() Param()
{ : game(), fade(), scoreboard(), title(), background(), balloon(),
balloon.reserve(4); notification(), service_menu(), intro(), debug(), resource() {}
}
}; };
// --- Variable global con los parámetros del juego --- // --- Variable global con los parámetros del juego ---