Balas funcionales
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
// Constructor
|
||||
Bullet::Bullet(int x, int y, int kind, bool poweredUp, int owner, LTexture *texture, SDL_Renderer *renderer)
|
||||
{
|
||||
mSprite = new Sprite({x,y,10,10},texture, renderer);
|
||||
mSprite = new Sprite({x, y, 10, 10}, texture, renderer);
|
||||
|
||||
// Posición inicial del objeto
|
||||
mPosX = x;
|
||||
@@ -12,7 +12,7 @@ Bullet::Bullet(int x, int y, int kind, bool poweredUp, int owner, LTexture *text
|
||||
|
||||
// Alto y ancho del objeto
|
||||
mWidth = 10;
|
||||
mHeight = mWidth;
|
||||
mHeight = 10;
|
||||
|
||||
// Velocidad inicial en el eje Y
|
||||
mVelY = -3;
|
||||
@@ -32,9 +32,13 @@ Bullet::Bullet(int x, int y, int kind, bool poweredUp, int owner, LTexture *text
|
||||
|
||||
// Rectangulo con los gráficos del objeto
|
||||
if (!poweredUp)
|
||||
{
|
||||
mSprite->setSpriteClip(0 * mWidth, 0, mSprite->getWidth(), mSprite->getHeight());
|
||||
}
|
||||
else
|
||||
{
|
||||
mSprite->setSpriteClip((0 + 3) * mWidth, 0, mSprite->getWidth(), mSprite->getHeight());
|
||||
}
|
||||
break;
|
||||
|
||||
case BULLET_LEFT:
|
||||
@@ -43,9 +47,13 @@ Bullet::Bullet(int x, int y, int kind, bool poweredUp, int owner, LTexture *text
|
||||
|
||||
// Rectangulo con los gráficos del objeto
|
||||
if (!poweredUp)
|
||||
{
|
||||
mSprite->setSpriteClip(1 * mWidth, 0, mSprite->getWidth(), mSprite->getHeight());
|
||||
}
|
||||
else
|
||||
{
|
||||
mSprite->setSpriteClip((1 + 3) * mWidth, 0, mSprite->getWidth(), mSprite->getHeight());
|
||||
}
|
||||
break;
|
||||
|
||||
case BULLET_RIGHT:
|
||||
@@ -54,9 +62,13 @@ Bullet::Bullet(int x, int y, int kind, bool poweredUp, int owner, LTexture *text
|
||||
|
||||
// Rectangulo con los gráficos del objeto
|
||||
if (!poweredUp)
|
||||
{
|
||||
mSprite->setSpriteClip(2 * mWidth, 0, mSprite->getWidth(), mSprite->getHeight());
|
||||
}
|
||||
else
|
||||
{
|
||||
mSprite->setSpriteClip((2 + 3) * mWidth, 0, mSprite->getWidth(), mSprite->getHeight());
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -74,7 +86,6 @@ Bullet::Bullet(int x, int y, int kind, bool poweredUp, int owner, LTexture *text
|
||||
Bullet::~Bullet()
|
||||
{
|
||||
delete mSprite;
|
||||
mSprite = nullptr;
|
||||
}
|
||||
|
||||
// Pinta el objeto en pantalla
|
||||
@@ -129,9 +140,19 @@ Uint8 Bullet::move()
|
||||
bool Bullet::isActive()
|
||||
{
|
||||
if (mKind == NO_KIND)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Desactiva el objeto
|
||||
void Bullet::deactivate()
|
||||
{
|
||||
mKind = NO_KIND;
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
|
||||
Reference in New Issue
Block a user