A medio integrar el objeto asset

This commit is contained in:
2022-08-08 21:19:10 +02:00
parent 4439f8477a
commit 0fa0368cca
2 changed files with 24 additions and 16 deletions

View File

@@ -213,6 +213,8 @@ void Director::initObjects()
{
eventHandler = new SDL_Event();
text.white = new Text("", nullptr, nullptr);
screen = new Screen(window, renderer);
asset = new Asset(path);
}
// Borra los objetos del programa
@@ -220,30 +222,32 @@ void Director::deleteObjects()
{
delete eventHandler;
delete text.white;
delete screen;
delete asset;
eventHandler = nullptr;
text.white = nullptr;
screen = nullptr;
asset = nullptr;
}
// Crea el indice de ficheros de recursos
void Director::setResourceList()
void Director::setFileList()
{
// Ficheros binarios
resource.file[FILE_MAP_VOLCANO].file = path + "/" + "../data/volcano.map";
resource.file[FILE_CONFIG].file = path + "/" + "../data/config.bin";
asset->add("/data/volcano.map",data);
asset->add("/data/config.bin".data);
// Texturas
resource.texture[TEXTURE_ACTORS].file = path + "/" + "../media/gfx/actors.png";
resource.texture[TEXTURE_BKG_SURFACE].file = path + "/" + "../media/gfx/bkg_surface.png";
resource.texture[TEXTURE_FILTER].file = path + "/" + "../media/gfx/filter.png";
resource.texture[TEXTURE_HUD].file = path + "/" + "../media/gfx/hud.png";
resource.texture[TEXTURE_MENU_ANIMATION].file = path + "/" + "../media/gfx/menu_animation.png";
resource.texture[TEXTURE_MENU].file = path + "/" + "../media/gfx/menu.png";
resource.texture[TEXTURE_PLAYER].file = path + "/" + "../media/gfx/player.png";
resource.texture[TEXTURE_TILES_SURFACE].file = path + "/" + "../media/gfx/tiles_surface.png";
resource.texture[TEXTURE_TILES_VOLCANO].file = path + "/" + "../media/gfx/tiles_volcano.png";
for (Uint8 i = 0; i < TOTAL_TEXTURE; i++)
resource.texture[i].texture = nullptr;
asset->add("/media/gfx/actors.png",bitmap);
asset->add("/media/gfx/bkg_surface.png",bitmap);
asset->add("/media/gfx/filter.png",bitmap);
asset->add("/media/gfx/hud.png",bitmap);
asset->add("/media/gfx/menu_animation.png",bitmap);
asset->add("/media/gfx/menu.png",bitmap);
asset->add("/media/gfx/player.png",bitmap);
asset->add("/media/gfx/tiles_surface.png",bitmap);
asset->add("/media/gfx/tiles_volcano.png",bitmap);
// Sonidos
resource.sound[SOUND_COIN].file = path + "/" + "../media/sound/sound_player_coin.wav";
resource.sound[SOUND_DEATH].file = path + "/" + "../media/sound/sound_player_death.wav";

View File

@@ -8,6 +8,8 @@
#include "const.h"
#include "jail_audio.h"
#include "utils.h"
#include "screen.h"
#include "asset.h"
#include <math.h>
#ifndef GAME_H
@@ -88,6 +90,8 @@ private:
double sen[360]; // Vector con los valores del seno para 360 grados
Player *player; // El jugador
Map *map; // El mapa del juego
Screen *screen; // Objeto para pintar en pantalla
Asset *asset; // Objeto con todos los ficheros de recursos
Uint32 scoreData[TOTAL_SCORE_DATA]; // Datos del fichero de puntuación
std::string path; // Path donde está el ejecutable del juego
enum _section // Lista con todas las secciones en las que se divide el programa
@@ -125,7 +129,7 @@ private:
void setPath(std::string _path);
// Crea el indice de ficheros de recursos
void setResourceList();
void setFileList();
// Comprueba que todos los ficheros de recursos existen
bool checkResourceList();