Trabajando en la cache de los recursos de los items

This commit is contained in:
2022-10-05 14:02:50 +02:00
parent 901757b9b2
commit 8076d8a765
5 changed files with 22 additions and 20 deletions

View File

@@ -183,7 +183,7 @@ bool AnimatedSprite::loadFromFile(std::string filePath)
if (file.good()) if (file.good())
{ {
// Procesa el fichero linea a linea // Procesa el fichero linea a linea
printf("Reading file %s\n", filename.c_str()); std::cout << "Loading animation from file: " << filePath.c_str() << std::endl;
while (std::getline(file, line)) while (std::getline(file, line))
{ {
// Si la linea contiene el texto [animation] se realiza el proceso de carga de una animación // Si la linea contiene el texto [animation] se realiza el proceso de carga de una animación
@@ -294,7 +294,6 @@ bool AnimatedSprite::loadFromFile(std::string filePath)
} }
// Cierra el fichero // Cierra el fichero
printf("Closing file %s\n\n", filename.c_str());
file.close(); file.close();
} }
// El fichero no se puede abrir // El fichero no se puede abrir

View File

@@ -49,11 +49,6 @@ Game::Game(int numPlayers, int currentStage, SDL_Renderer *renderer, Screen *scr
grassSprite = new Sprite(0, 0, 256, 6, gameGrassTexture, renderer); grassSprite = new Sprite(0, 0, 256, 6, gameGrassTexture, renderer);
powerMeterSprite = new Sprite(PLAY_AREA_CENTER_X - 20, 170, 40, 7, gamePowerMeterTexture, renderer); powerMeterSprite = new Sprite(PLAY_AREA_CENTER_X - 20, 170, 40, 7, gamePowerMeterTexture, renderer);
// Carga ficheros
loadScoreFile();
loadDemoFile();
// Inicializa las variables necesarias para la sección 'Game' // Inicializa las variables necesarias para la sección 'Game'
init(); init();
} }
@@ -335,7 +330,12 @@ void Game::init()
// Carga los recursos necesarios para la sección 'Game' // Carga los recursos necesarios para la sección 'Game'
void Game::loadMedia() void Game::loadMedia()
{ {
std::cout << "** LOADING RESOURCES FOR GAME SECTION" << std::endl; std::cout << std::endl
<< "** LOADING RESOURCES FOR GAME SECTION" << std::endl;
// Carga ficheros
loadScoreFile();
loadDemoFile();
// Texturas // Texturas
balloon1Texture = new LTexture(renderer, asset->get("balloon1.png")); balloon1Texture = new LTexture(renderer, asset->get("balloon1.png"));
@@ -388,7 +388,8 @@ void Game::loadMedia()
// Musicas // Musicas
gameMusic = JA_LoadMusic(asset->get("playing.ogg").c_str()); gameMusic = JA_LoadMusic(asset->get("playing.ogg").c_str());
std::cout << "** RESOURCES FOR GAME SECTION LOADED" << std::endl << std::endl; std::cout << "** RESOURCES FOR GAME SECTION LOADED" << std::endl
<< std::endl;
} }
// Carga el fichero de puntos // Carga el fichero de puntos

View File

@@ -130,6 +130,7 @@ private:
LTexture *balloon3Texture; // Textura para los globos LTexture *balloon3Texture; // Textura para los globos
LTexture *balloon4Texture; // Textura para los globos LTexture *balloon4Texture; // Textura para los globos
LTexture *bulletTexture; // Textura para las balas LTexture *bulletTexture; // Textura para las balas
std::vector<LTexture *> itemTexture; // Vector con las texturas de los items
LTexture *gameBuildingsTexture; // Textura con los edificios de fondo LTexture *gameBuildingsTexture; // Textura con los edificios de fondo
LTexture *gameCloudsTexture; // Textura con las nubes de fondo LTexture *gameCloudsTexture; // Textura con las nubes de fondo
@@ -144,6 +145,7 @@ private:
std::vector<std::string> *balloon2Animation; // Información para la animación de los globos std::vector<std::string> *balloon2Animation; // Información para la animación de los globos
std::vector<std::string> *balloon3Animation; // Información para la animación de los globos std::vector<std::string> *balloon3Animation; // Información para la animación de los globos
std::vector<std::string> *balloon4Animation; // Información para la animación de los globos std::vector<std::string> *balloon4Animation; // Información para la animación de los globos
std::vector<std::vector<std::string>> *itemAnimations; // Vector con las animaciones de los items
Text *text; // Fuente para los textos del juego Text *text; // Fuente para los textos del juego
Text *textBig; // Fuente de texto grande Text *textBig; // Fuente de texto grande

View File

@@ -157,7 +157,7 @@ bool Menu::load(std::string file_path)
} }
// Cierra el fichero // Cierra el fichero
printf("Closing file %s\n\n", filename.c_str()); printf("Closing file %s\n", filename.c_str());
file.close(); file.close();
} }
// El fichero no se puede abrir // El fichero no se puede abrir

View File

@@ -151,7 +151,7 @@ void Text::initOffsetFromFile(std::string file)
}; };
// Cierra el fichero // Cierra el fichero
printf("Text loaded: %s\n\n", filename.c_str()); printf("Text loaded: %s\n", filename.c_str());
rfile.close(); rfile.close();
} }