Revisada la carrega de recursos en game.cpp

This commit is contained in:
2024-10-18 14:07:25 +02:00
parent 8e8346b2ab
commit afe835914e
12 changed files with 101 additions and 148 deletions

View File

@@ -38,22 +38,17 @@ void Explosions::render()
}
// Añade texturas al objeto
void Explosions::addTexture(int size, std::shared_ptr<Texture> texture, std::vector<std::string> *animation)
void Explosions::addTexture(int size, std::shared_ptr<Texture> texture, std::vector<std::string> &animation)
{
ExplosionTexture temp;
temp.size = size;
temp.texture = texture;
temp.animation = animation;
textures_.push_back(temp);
textures_.emplace_back(ExplosionTexture(size, texture, animation));
}
// Añade una explosión
void Explosions::add(int x, int y, int size)
{
const int index = getIndexBySize(size);
auto sprite = std::make_unique<AnimatedSprite>(textures_[index].texture, textures_[index].animation);
sprite->setPos(x, y);
explosions_.push_back(std::move(sprite));
const auto index = getIndexBySize(size);
explosions_.emplace_back(std::make_unique<AnimatedSprite>(textures_[index].texture, textures_[index].animation));
explosions_.back()->setPos(x, y);
}
// Vacia el vector de elementos finalizados