Arreglos varios al codi

This commit is contained in:
2024-10-08 22:38:58 +02:00
parent 3e3d764b25
commit bd3aa0bb06
30 changed files with 177 additions and 227 deletions

View File

@@ -9,7 +9,7 @@
// Constructor
Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 creationtimer, Texture *texture, std::vector<std::string> *animation)
{
sprite = new AnimatedSprite(texture, "", animation);
sprite = std::make_unique<AnimatedSprite>(texture, "", animation);
disable();
enabled = true;
@@ -274,12 +274,6 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c
this->kind = kind;
}
// Destructor
Balloon::~Balloon()
{
delete sprite;
}
// Centra el globo en la posición X
void Balloon::allignTo(int x)
{
@@ -333,10 +327,9 @@ void Balloon::render()
if (kind == POWER_BALL && !isBeingCreated())
{
Sprite *sp = new Sprite(sprite->getRect(), sprite->getTexture());
auto sp = std::make_unique<Sprite>(sprite->getRect(), sprite->getTexture());
sp->setSpriteClip(BALLOON_WIDTH_4, 0, BALLOON_WIDTH_4, BALLOON_WIDTH_4);
sp->render();
delete sp;
}
}
}
@@ -601,37 +594,37 @@ void Balloon::updateAnimation()
}
// Comprueba si el globo está habilitado
bool Balloon::isEnabled()
bool Balloon::isEnabled() const
{
return enabled;
}
// Obtiene del valor de la variable
float Balloon::getPosX()
float Balloon::getPosX() const
{
return posX;
}
// Obtiene del valor de la variable
float Balloon::getPosY()
float Balloon::getPosY() const
{
return posY;
}
// Obtiene del valor de la variable
float Balloon::getVelY()
float Balloon::getVelY() const
{
return velY;
}
// Obtiene del valor de la variable
int Balloon::getWidth()
int Balloon::getWidth() const
{
return width;
}
// Obtiene del valor de la variable
int Balloon::getHeight()
int Balloon::getHeight() const
{
return height;
}
@@ -649,19 +642,19 @@ void Balloon::setSpeed(float speed)
}
// Obtiene del valor de la variable
int Balloon::getKind()
int Balloon::getKind() const
{
return kind;
}
// Obtiene del valor de la variable
Uint8 Balloon::getSize()
Uint8 Balloon::getSize() const
{
return size;
}
// Obtiene la clase a la que pertenece el globo
Uint8 Balloon::getClass()
Uint8 Balloon::getClass() const
{
if ((kind >= BALLOON_1) && (kind <= BALLOON_4))
{
@@ -683,7 +676,7 @@ void Balloon::setStop(bool state)
}
// Obtiene del valor de la variable
bool Balloon::isStopped()
bool Balloon::isStopped() const
{
return stopped;
}
@@ -695,7 +688,7 @@ void Balloon::setBlink(bool value)
}
// Obtiene del valor de la variable
bool Balloon::isBlinking()
bool Balloon::isBlinking() const
{
return blinking;
}
@@ -707,7 +700,7 @@ void Balloon::setVisible(bool value)
}
// Obtiene del valor de la variable
bool Balloon::isVisible()
bool Balloon::isVisible() const
{
return visible;
}
@@ -719,7 +712,7 @@ void Balloon::setInvulnerable(bool value)
}
// Obtiene del valor de la variable
bool Balloon::isInvulnerable()
bool Balloon::isInvulnerable() const
{
return invulnerable;
}
@@ -731,7 +724,7 @@ void Balloon::setBeingCreated(bool value)
}
// Obtiene del valor de la variable
bool Balloon::isBeingCreated()
bool Balloon::isBeingCreated() const
{
return beingCreated;
}
@@ -743,13 +736,13 @@ void Balloon::setStoppedTimer(Uint16 time)
}
// Obtiene del valor de la variable
Uint16 Balloon::getStoppedTimer()
Uint16 Balloon::getStoppedTimer() const
{
return stoppedCounter;
}
// Obtiene del valor de la variable
Uint16 Balloon::getScore()
Uint16 Balloon::getScore() const
{
return score;
}
@@ -768,7 +761,7 @@ void Balloon::updateColliders()
}
// Obtiene le valor de la variable
Uint8 Balloon::getMenace()
Uint8 Balloon::getMenace() const
{
if (isEnabled())
{
@@ -781,7 +774,7 @@ Uint8 Balloon::getMenace()
}
// Obtiene le valor de la variable
Uint8 Balloon::getPower()
Uint8 Balloon::getPower() const
{
return power;
}
@@ -828,13 +821,13 @@ void Balloon::updateBounce()
}
// Indica si el globo se puede explotar
bool Balloon::canBePopped()
bool Balloon::canBePopped() const
{
return isEnabled() && !isBeingCreated();
}
// Indica si el globo se puede destruir
bool Balloon::canBeDestroyed()
bool Balloon::canBeDestroyed() const
{
return isEnabled();
}