Muntat a c++14 per a make_unique
Mes autos, const i constexpr perl codi Ara la classe Screen es un poc pitjor
This commit is contained in:
@@ -13,14 +13,13 @@ constexpr int BULLET_VELX_RIGHT = 2;
|
||||
// Constructor
|
||||
Bullet::Bullet(int x, int y, BulletType kind, bool poweredUp, int owner, SDL_Rect *playArea, Texture *texture)
|
||||
: posX(x), posY(y), width(BULLET_WIDTH), height(BULLET_HEIGHT), velX(0), velY(BULLET_VELY),
|
||||
kind(kind), owner(owner), playArea(playArea),
|
||||
sprite(std::unique_ptr<Sprite>(new Sprite(SDL_Rect{x, y, BULLET_WIDTH, BULLET_HEIGHT}, texture))) // Crear manualmente el std::unique_ptr
|
||||
kind(kind), owner(owner), playArea(playArea)
|
||||
{
|
||||
velX = (kind == BulletType::LEFT) ? BULLET_VELX_LEFT : (kind == BulletType::RIGHT) ? BULLET_VELX_RIGHT
|
||||
: 0;
|
||||
velX = (kind == BulletType::LEFT) ? BULLET_VELX_LEFT : (kind == BulletType::RIGHT) ? BULLET_VELX_RIGHT : 0;
|
||||
|
||||
auto spriteOffset = poweredUp ? 3 : 0;
|
||||
auto kindIndex = static_cast<int>(kind);
|
||||
sprite = std::make_unique<Sprite>(SDL_Rect{x, y, BULLET_WIDTH, BULLET_HEIGHT}, texture);
|
||||
sprite->setSpriteClip((kindIndex + spriteOffset) * width, 0, sprite->getWidth(), sprite->getHeight());
|
||||
|
||||
collider.r = width / 2;
|
||||
|
||||
Reference in New Issue
Block a user