Files
jaildoctors_dilemma/source/common/resource.h

68 lines
1.3 KiB
C++

#pragma once
#include <SDL2/SDL.h>
#include "animatedsprite.h"
#include "asset.h"
#include "texture.h"
#include "utils.h"
#include <string>
#include <vector>
#ifndef RESOURCE_H
#define RESOURCE_H
struct texture_t
{
std::string name; // Nombre de la textura
Texture *texture; // La textura
};
struct animation_t
{
std::string name; // Nombre de la textura
animatedSprite_t *animation; // La animación
};
class Resource
{
private:
// Objetos y punteros
SDL_Renderer *renderer; // El renderizador de la ventana
Asset *asset; // Objeto con la ruta a todos los ficheros de recursos
options_t *options; // Puntero a las opciones del juego
// Variables
std::vector<texture_t> textures;
std::vector<animation_t> animations;
public:
// Constructor
Resource(SDL_Renderer *renderer, Asset *asset, options_t *options);
// Carga las texturas de una lista
void loadTextures(std::vector<std::string> list);
// Carga las animaciones desde una lista
void loadAnimations(std::vector<std::string> list);
// Recarga las texturas
void reLoadTextures();
// Libera las texturas
void freeTextures();
// Libera las animaciones
void freeAnimations();
// Libera todos los recursos
void free();
// Obtiene una textura
Texture *getTexture(std::string name);
// Obtiene una animación
animatedSprite_t *getAnimation(std::string name);
};
#endif