From 8076d8a765a7c14e358390e7d6bc1e3644432260 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Wed, 5 Oct 2022 14:02:50 +0200 Subject: [PATCH] Trabajando en la cache de los recursos de los items --- source/animatedsprite.cpp | 3 +-- source/game.cpp | 15 ++++++++------- source/game.h | 20 +++++++++++--------- source/menu.cpp | 2 +- source/text.cpp | 2 +- 5 files changed, 22 insertions(+), 20 deletions(-) diff --git a/source/animatedsprite.cpp b/source/animatedsprite.cpp index c11924f..4775e24 100644 --- a/source/animatedsprite.cpp +++ b/source/animatedsprite.cpp @@ -183,7 +183,7 @@ bool AnimatedSprite::loadFromFile(std::string filePath) if (file.good()) { // 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)) { // 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 - printf("Closing file %s\n\n", filename.c_str()); file.close(); } // El fichero no se puede abrir diff --git a/source/game.cpp b/source/game.cpp index a4eac53..b768ed5 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -49,11 +49,6 @@ Game::Game(int numPlayers, int currentStage, SDL_Renderer *renderer, Screen *scr grassSprite = new Sprite(0, 0, 256, 6, gameGrassTexture, 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' init(); } @@ -335,7 +330,12 @@ void Game::init() // Carga los recursos necesarios para la sección 'Game' 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 balloon1Texture = new LTexture(renderer, asset->get("balloon1.png")); @@ -388,7 +388,8 @@ void Game::loadMedia() // Musicas 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 diff --git a/source/game.h b/source/game.h index 937feda..8c76965 100644 --- a/source/game.h +++ b/source/game.h @@ -125,11 +125,12 @@ private: std::vector items; // Vector con los items std::vector smartSprites; // Vector con los smartsprites - LTexture *balloon1Texture; // Textura para los globos - LTexture *balloon2Texture; // Textura para los globos - LTexture *balloon3Texture; // Textura para los globos - LTexture *balloon4Texture; // Textura para los globos - LTexture *bulletTexture; // Textura para las balas + LTexture *balloon1Texture; // Textura para los globos + LTexture *balloon2Texture; // Textura para los globos + LTexture *balloon3Texture; // Textura para los globos + LTexture *balloon4Texture; // Textura para los globos + LTexture *bulletTexture; // Textura para las balas + std::vector itemTexture; // Vector con las texturas de los items LTexture *gameBuildingsTexture; // Textura con los edificios de fondo LTexture *gameCloudsTexture; // Textura con las nubes de fondo @@ -140,10 +141,11 @@ private: LTexture *itemTexture; // Textura para los items - std::vector *balloon1Animation; // Información para la animación de los globos - std::vector *balloon2Animation; // Información para la animación de los globos - std::vector *balloon3Animation; // Información para la animación de los globos - std::vector *balloon4Animation; // Información para la animación de los globos + std::vector *balloon1Animation; // Información para la animación de los globos + std::vector *balloon2Animation; // Información para la animación de los globos + std::vector *balloon3Animation; // Información para la animación de los globos + std::vector *balloon4Animation; // Información para la animación de los globos + std::vector> *itemAnimations; // Vector con las animaciones de los items Text *text; // Fuente para los textos del juego Text *textBig; // Fuente de texto grande diff --git a/source/menu.cpp b/source/menu.cpp index bb20488..8a969cc 100644 --- a/source/menu.cpp +++ b/source/menu.cpp @@ -157,7 +157,7 @@ bool Menu::load(std::string file_path) } // Cierra el fichero - printf("Closing file %s\n\n", filename.c_str()); + printf("Closing file %s\n", filename.c_str()); file.close(); } // El fichero no se puede abrir diff --git a/source/text.cpp b/source/text.cpp index 91df9c3..b7c6eb7 100644 --- a/source/text.cpp +++ b/source/text.cpp @@ -151,7 +151,7 @@ void Text::initOffsetFromFile(std::string file) }; // Cierra el fichero - printf("Text loaded: %s\n\n", filename.c_str()); + printf("Text loaded: %s\n", filename.c_str()); rfile.close(); }