Treballant en el zoom del titol s'ha arreglat el rebot dels globos i ara mola mes, o aixo pense

This commit is contained in:
2024-12-03 13:59:40 +01:00
parent 3c5bbf2ab0
commit 80e366b208
2 changed files with 15 additions and 18 deletions

View File

@@ -106,6 +106,7 @@ void Balloon::render()
SDL_Point p = {24, 24};
sprite_->setRotatingCenter(&p);
sprite_->render();
// Añade la máscara del borde y los reflejos
auto sp = std::make_unique<Sprite>(sprite_->getTexture(), sprite_->getPosition());
sp->setSpriteClip(BALLOON_SIZE[4], 0, BALLOON_SIZE[4], BALLOON_SIZE[4]);
@@ -122,22 +123,12 @@ void Balloon::render()
sprite_->getTexture()->setAlpha(255);
}
else
{
if (bouncing_.enabled)
{
// Renderizado con efecto de bouncing
sprite_->setPos(x_ + bouncing_.despX, y_ + bouncing_.despY);
sprite_->render();
// sprite_->setPos(x_ - bouncing_.despX, y_ - bouncing_.despY);
}
else
{
// Renderizado normal
sprite_->render();
}
}
}
}
// Actualiza la posición y estados del globo
void Balloon::move()
@@ -388,14 +379,12 @@ void Balloon::updateBounce()
zoomSprite();
const auto spriteClip = sprite_->getSpriteClip();
bouncing_.despX = spriteClip.w * (1.0f - bouncing_.zoomW);
bouncing_.despY = spriteClip.h * (1.0f - bouncing_.zoomH);
if (++bouncing_.counter / bouncing_.speed >= MAX_BOUNCE)
{
disableBounce();
}
}
}
// Pone el color alternativo en el globo
void Balloon::useReverseColor()

View File

@@ -190,8 +190,16 @@ void Texture::render(int x, int y, SDL_Rect *clip, float zoomW, float zoomH, dou
renderQuad.h = clip->h;
}
// Calcula el zoom y las coordenadas
if (zoomH != 1.0f || zoomW != 1.0f)
{
renderQuad.x = renderQuad.x + (renderQuad.w / 2);
renderQuad.y = renderQuad.y + (renderQuad.h / 2);
renderQuad.w = renderQuad.w * zoomW;
renderQuad.h = renderQuad.h * zoomH;
renderQuad.x = renderQuad.x - (renderQuad.w / 2);
renderQuad.y = renderQuad.y - (renderQuad.h / 2);
}
// Renderiza a pantalla
SDL_RenderCopyEx(renderer_, texture_, clip, &renderQuad, angle, center, flip);