forked from jaildesigner-jailgames/jaildoctors_dilemma
Empezando a trabajar en la precarga de recursos para el juego
This commit is contained in:
@@ -24,6 +24,9 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *opti
|
||||
spawnPoint = {x * 8, y * 8, 0, 0, 0, s_standing, SDL_FLIP_HORIZONTAL};
|
||||
// ****
|
||||
|
||||
// Crea la cache de recursos
|
||||
cacheResources();
|
||||
|
||||
// Crea los objetos
|
||||
scoreboard = new ScoreBoard(renderer, asset, options, &board);
|
||||
itemTracker = new ItemTracker();
|
||||
@@ -58,6 +61,9 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *opti
|
||||
|
||||
Game::~Game()
|
||||
{
|
||||
// Libera los recursos
|
||||
freeCache();
|
||||
|
||||
// Libera la memoria de los objetos
|
||||
delete scoreboard;
|
||||
delete itemTracker;
|
||||
@@ -453,4 +459,87 @@ void Game::renderBlackScreen()
|
||||
screen->clean();
|
||||
screen->setBorderColor(stringToColor(options->palette, "black"));
|
||||
}
|
||||
}
|
||||
|
||||
// Carga todos los recursos necesarios
|
||||
void Game::cacheResources()
|
||||
{
|
||||
// Carga las texturas
|
||||
std::vector<std::string> textureList;
|
||||
|
||||
// Jugador
|
||||
textureList.push_back("player.png");
|
||||
|
||||
// Tilesets
|
||||
textureList.push_back("standard.png");
|
||||
textureList.push_back("standard_zxarne.png");
|
||||
|
||||
// Enemigos
|
||||
textureList.push_back("paco.png");
|
||||
textureList.push_back("chip.png");
|
||||
textureList.push_back("wave.png");
|
||||
textureList.push_back("wave_v.png");
|
||||
textureList.push_back("sigmasua.png");
|
||||
textureList.push_back("diskette.png");
|
||||
textureList.push_back("bird.png");
|
||||
textureList.push_back("bin.png");
|
||||
textureList.push_back("qvoid.png");
|
||||
textureList.push_back("batman.png");
|
||||
textureList.push_back("tuno.png");
|
||||
textureList.push_back("matatunos.png");
|
||||
textureList.push_back("abad.png");
|
||||
textureList.push_back("jailbattle_human.png");
|
||||
textureList.push_back("jailbattle_alien.png");
|
||||
textureList.push_back("jailer.png");
|
||||
textureList.push_back("jailer2.png");
|
||||
textureList.push_back("jailer3.png");
|
||||
textureList.push_back("printer.png");
|
||||
textureList.push_back("code.png");
|
||||
textureList.push_back("demon.png");
|
||||
textureList.push_back("dimallas.png");
|
||||
textureList.push_back("dimallas_v.png");
|
||||
textureList.push_back("heavy.png");
|
||||
textureList.push_back("spider.png");
|
||||
textureList.push_back("macaronni_ted.png");
|
||||
textureList.push_back("mummy.png");
|
||||
textureList.push_back("sam.png");
|
||||
textureList.push_back("amstrad_character_set.png");
|
||||
textureList.push_back("breakout.png");
|
||||
textureList.push_back("lamp.png");
|
||||
textureList.push_back("bry.png");
|
||||
textureList.push_back("tv.png");
|
||||
textureList.push_back("tv_panel.png");
|
||||
textureList.push_back("arounders_door.png");
|
||||
textureList.push_back("arounders_machine.png");
|
||||
textureList.push_back("arounder_walk.png");
|
||||
textureList.push_back("arounder_stop.png");
|
||||
textureList.push_back("arounder_fly.png");
|
||||
textureList.push_back("bat.png");
|
||||
|
||||
// Items
|
||||
textureList.push_back("items.png");
|
||||
|
||||
// Texto
|
||||
textureList.push_back("smb2.png");
|
||||
textureList.push_back("debug.png");
|
||||
|
||||
for (auto list : textureList)
|
||||
{
|
||||
texture_t t;
|
||||
t.name = list;
|
||||
t.texture = new Texture(renderer, asset->get(t.name));
|
||||
textures.push_back(t);
|
||||
}
|
||||
}
|
||||
|
||||
// Libera los recursos
|
||||
void Game::freeCache()
|
||||
{
|
||||
// Libera las texturas
|
||||
for (auto texture : textures)
|
||||
{
|
||||
texture.texture->unload();
|
||||
delete texture.texture;
|
||||
}
|
||||
textures.clear();
|
||||
}
|
||||
Reference in New Issue
Block a user