48 lines
1.2 KiB
C++
48 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include <string> // for string
|
|
#include <vector> // for vector
|
|
#include "animated_sprite.h"
|
|
#include <memory>
|
|
#include "texture.h"
|
|
|
|
struct explosion_texture_t
|
|
{
|
|
std::shared_ptr<Texture>texture; // Textura para la explosión
|
|
std::vector<std::string> *animation; // Animación para la textura
|
|
int size; // Tamaño de la explosión
|
|
};
|
|
|
|
// Clase explosions
|
|
class Explosions
|
|
{
|
|
private:
|
|
// Variables
|
|
std::vector<explosion_texture_t> textures; // Vector con las texturas a utilizar
|
|
std::vector<std::unique_ptr<AnimatedSprite>> explosions; // Lista con todas las explosiones
|
|
|
|
// Vacia el vector de elementos finalizados
|
|
void freeExplosions();
|
|
|
|
// Busca una textura a partir del tamaño
|
|
int getIndexBySize(int size);
|
|
|
|
public:
|
|
// Constructor
|
|
Explosions();
|
|
|
|
// Destructor
|
|
~Explosions();
|
|
|
|
// Actualiza la lógica de la clase
|
|
void update();
|
|
|
|
// Dibuja el objeto en pantalla
|
|
void render();
|
|
|
|
// Añade texturas al objeto
|
|
void addTexture(int size, std::shared_ptr<Texture> texture, std::vector<std::string> *animation);
|
|
|
|
// Añade una explosión
|
|
void add(int x, int y, int size);
|
|
}; |