clang-tidy readability-function-cognitive-complexity
This commit is contained in:
@@ -13,30 +13,45 @@ Bullet::Bullet(float x, float y, BulletType bullet_type, bool powered, int owner
|
||||
pos_y_(y),
|
||||
bullet_type_(bullet_type),
|
||||
owner_(owner) {
|
||||
vel_x_ = (bullet_type_ == BulletType::LEFT) ? VEL_X_LEFT
|
||||
: (bullet_type_ == BulletType::RIGHT) ? VEL_X_RIGHT
|
||||
: 0;
|
||||
|
||||
vel_x_ = calculateVelocity(bullet_type_);
|
||||
sprite_->setCurrentAnimation(buildAnimationString(bullet_type_, powered));
|
||||
|
||||
collider_.r = WIDTH / 2;
|
||||
shiftColliders();
|
||||
}
|
||||
|
||||
std::string powered_type = powered ? "powered_" : "normal_";
|
||||
// Calcula la velocidad horizontal de la bala basada en su tipo
|
||||
float Bullet::calculateVelocity(BulletType bullet_type) {
|
||||
switch (bullet_type) {
|
||||
case BulletType::LEFT:
|
||||
return VEL_X_LEFT;
|
||||
case BulletType::RIGHT:
|
||||
return VEL_X_RIGHT;
|
||||
default:
|
||||
return VEL_X_CENTER;
|
||||
}
|
||||
}
|
||||
|
||||
// Construye el string de animación basado en el tipo de bala y si está potenciada
|
||||
std::string Bullet::buildAnimationString(BulletType bullet_type, bool powered) {
|
||||
std::string animation_string = powered ? "powered_" : "normal_";
|
||||
|
||||
switch (bullet_type) {
|
||||
case BulletType::UP:
|
||||
sprite_->setCurrentAnimation(powered_type + "up");
|
||||
animation_string += "up";
|
||||
break;
|
||||
|
||||
case BulletType::LEFT:
|
||||
sprite_->setCurrentAnimation(powered_type + "left");
|
||||
animation_string += "left";
|
||||
break;
|
||||
|
||||
case BulletType::RIGHT:
|
||||
sprite_->setCurrentAnimation(powered_type + "right");
|
||||
animation_string += "right";
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
collider_.r = WIDTH / 2;
|
||||
shiftColliders();
|
||||
|
||||
return animation_string;
|
||||
}
|
||||
|
||||
// Implementación de render (llama al render del sprite_)
|
||||
|
||||
Reference in New Issue
Block a user