From de2a29b6696e1a0a4d2d8b415855b5e28cbb2300 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Sat, 26 Oct 2024 12:23:04 +0200 Subject: [PATCH] Ajustado el game_text para que se dibuje siempre en pantalla, sin clipping --- source/game.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/source/game.cpp b/source/game.cpp index 9c78609..3cafefe 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -976,11 +976,17 @@ void Game::createItemScoreSprite(int x, int y, std::shared_ptr texture) { smart_sprites_.emplace_back(std::make_unique(texture)); + const auto w = texture->getWidth(); + const auto h = texture->getHeight(); + + // Ajusta para que no se dibuje fuera de pantalla + x = std::clamp(x, 0, param.game.play_area.rect.w - w); + // Inicializa - smart_sprites_.back()->setPos({0, 0, texture->getWidth(), texture->getHeight()}); - smart_sprites_.back()->setSpriteClip(smart_sprites_.back()->getPosition()); + smart_sprites_.back()->setPos({0, 0, w, h}); + smart_sprites_.back()->setSpriteClip({0, 0, w, h}); smart_sprites_.back()->setPosX(x); - smart_sprites_.back()->setPosY(param.game.play_area.rect.h - texture->getHeight()); + smart_sprites_.back()->setPosY(param.game.play_area.rect.h - h); smart_sprites_.back()->setDestX(x); smart_sprites_.back()->setDestY(y - 35); smart_sprites_.back()->setVelY(-0.5f);