modificada la classe balloon: eliminat el estat popping i dibuixat desde fitxers gif, pero no funciona el canvi de paleta

This commit is contained in:
2024-07-28 18:08:40 +02:00
parent f1159f2bf3
commit 8d9d0eaaf3
6 changed files with 140 additions and 170 deletions

View File

@@ -256,7 +256,6 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c
beingCreated = true;
creationCounter = creationtimer;
creationCounterIni = creationtimer;
popping = false;
// Actualiza valores
beingCreated = creationCounter == 0 ? false : true;
@@ -318,28 +317,23 @@ void Balloon::render()
else if (isBeingCreated())
{
// Aplica alpha blending
//sprite->getTexture()->setPalette(1);
sprite->getTexture()->setAlpha(255 - (int)((float)creationCounter * (255.0f / (float)creationCounterIni)));
sprite->render();
if (kind == POWER_BALL)
{
Sprite *sp = new Sprite(sprite->getRect(), sprite->getTexture());
sp->setSpriteClip(407, 0, 37, 37);
sp->render();
delete sp;
}
sprite->getTexture()->setAlpha(255);
}
else
{
//sprite->getTexture()->setPalette(0);
sprite->render();
}
if (kind == POWER_BALL and !popping)
{
Sprite *sp = new Sprite(sprite->getRect(), sprite->getTexture());
sp->setSpriteClip(407, 0, 37, 37);
sp->render();
delete sp;
}
if (kind == POWER_BALL)
{
Sprite *sp = new Sprite(sprite->getRect(), sprite->getTexture());
sp->setSpriteClip(BALLOON_WIDTH_4, 0, BALLOON_WIDTH_4, BALLOON_WIDTH_4);
sp->render();
delete sp;
}
}
}
@@ -458,7 +452,6 @@ void Balloon::disable()
kind = 0;
maxVelY = 0.0f;
menace = 0;
popping = false;
posX = 0.0f;
posY = 0.0f;
power = 0;
@@ -478,12 +471,7 @@ void Balloon::disable()
// Explosiona el globo
void Balloon::pop()
{
setPopping(true);
sprite->disableRotate();
setStop(true);
setStoppedTimer(2000);
setInvulnerable(true);
menace = 0;
disable();
}
// Actualiza al globo a su posicion, animación y controla los contadores
@@ -504,17 +492,6 @@ void Balloon::update()
// Actualiza los estados del globo
void Balloon::updateState()
{
// Si está explotando
if (isPopping())
{
setInvulnerable(true);
setStop(true);
if (sprite->animationIsCompleted())
{
disable();
}
}
// Si se está creando
if (isBeingCreated())
{
@@ -577,8 +554,8 @@ void Balloon::updateState()
stoppedCounter--;
}
// Si el contador ha llegado a cero
else if (!isPopping())
{ // Quitarles el estado "detenido" si no estan explosionando
else
{ // Quitarles el estado "detenido"
setStop(false);
// Si es una powerball vuelve a rodar
@@ -593,26 +570,22 @@ void Balloon::updateState()
// Establece la animación correspondiente al estado
void Balloon::updateAnimation()
{
std::string creatingAnimation = "blue";
std::string normalAnimation = "orange";
std::string creatingAnimation = "stopped";
std::string normalAnimation = "normal";
if (kind == POWER_BALL)
{
creatingAnimation = "powerball";
normalAnimation = "powerball";
creatingAnimation = "default";
normalAnimation = "default";
}
else if (getClass() == HEXAGON_CLASS)
{
creatingAnimation = "red";
normalAnimation = "green";
creatingAnimation = "stopped";
normalAnimation = "normal";
}
// Establece el frame de animación
if (isPopping())
{
sprite->setCurrentAnimation("pop");
}
else if (isBeingCreated())
if (isBeingCreated())
{
sprite->setCurrentAnimation(creatingAnimation);
}
@@ -760,18 +733,6 @@ bool Balloon::isBeingCreated()
return beingCreated;
}
// Establece el valor de la variable
void Balloon::setPopping(bool value)
{
popping = value;
}
// Obtiene del valor de la variable
bool Balloon::isPopping()
{
return popping;
}
// Establece el valor de la variable
void Balloon::setStoppedTimer(Uint16 time)
{
@@ -866,11 +827,11 @@ void Balloon::updateBounce()
// Indica si el globo se puede explotar
bool Balloon::canBePopped()
{
return isEnabled() && !isPopping() && !isBeingCreated();
return isEnabled() && !isBeingCreated();
}
// Indica si el globo se puede destruir
bool Balloon::canBeDestroyed()
{
return isEnabled() && !isPopping();
return isEnabled();
}