Afegides recomanacions de cppcheck
Optimitzada la funció updateBalloonSpeed() i eliminades funcions sobrants o redundants
This commit is contained in:
@@ -11,16 +11,24 @@ constexpr int BULLET_VELX_LEFT = -2;
|
||||
constexpr int BULLET_VELX_RIGHT = 2;
|
||||
|
||||
// Constructor
|
||||
Bullet::Bullet(int x, int y, BulletType kind_, bool poweredUp, int owner, SDL_Rect *play_area, std::shared_ptr<Texture> texture)
|
||||
: pos_x_(x), pos_y_(y), width_(BULLET_WIDTH), height_(BULLET_HEIGHT), vel_x_(0), vel_y_(BULLET_VELY),
|
||||
kind_(kind_), owner_(owner), play_area_(play_area)
|
||||
Bullet::Bullet(int x, int y, BulletType kind, bool powered_up, int owner, SDL_Rect *play_area, std::shared_ptr<Texture> texture)
|
||||
: sprite_(std::make_unique<Sprite>(SDL_Rect{x, y, BULLET_WIDTH, BULLET_HEIGHT}, texture)),
|
||||
pos_x_(x),
|
||||
pos_y_(y),
|
||||
width_(BULLET_WIDTH),
|
||||
height_(BULLET_HEIGHT),
|
||||
vel_x_(0),
|
||||
vel_y_(BULLET_VELY),
|
||||
kind_(kind),
|
||||
owner_(owner),
|
||||
play_area_(play_area)
|
||||
{
|
||||
vel_x_ = (kind_ == BulletType::LEFT) ? BULLET_VELX_LEFT : (kind_ == BulletType::RIGHT) ? BULLET_VELX_RIGHT
|
||||
: 0;
|
||||
|
||||
auto sprite_offset = poweredUp ? 3 : 0;
|
||||
auto kind_index = static_cast<int>(kind_);
|
||||
sprite_ = std::make_unique<Sprite>(SDL_Rect{x, y, BULLET_WIDTH, BULLET_HEIGHT}, texture);
|
||||
vel_x_ = (kind_ == BulletType::LEFT) ? BULLET_VELX_LEFT
|
||||
: (kind_ == BulletType::RIGHT) ? BULLET_VELX_RIGHT
|
||||
: 0;
|
||||
|
||||
auto sprite_offset = powered_up ? 3 : 0;
|
||||
auto kind_index = static_cast<int>(kind);
|
||||
sprite_->setSpriteClip((kind_index + sprite_offset) * width_, 0, sprite_->getWidth(), sprite_->getHeight());
|
||||
|
||||
collider_.r = width_ / 2;
|
||||
|
||||
Reference in New Issue
Block a user