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);