diff --git a/resources.pack b/resources.pack deleted file mode 100644 index 672954c..0000000 Binary files a/resources.pack and /dev/null differ diff --git a/source/engine.cpp b/source/engine.cpp index 9002790..f37dd8b 100644 --- a/source/engine.cpp +++ b/source/engine.cpp @@ -147,22 +147,22 @@ bool Engine::initialize(int width, int height, int zoom, bool fullscreen) { if (fs::exists(balls_dir) && fs::is_directory(balls_dir)) { struct TextureInfo { std::string name; - std::string path; + std::shared_ptr texture; int width; }; std::vector texture_files; - // Cargar información de todas las texturas (incluyendo dimensiones) + // Cargar todas las texturas (solo una vez) for (const auto& entry : fs::directory_iterator(balls_dir)) { if (entry.is_regular_file() && entry.path().extension() == ".png") { std::string filename = entry.path().stem().string(); std::string fullpath = entry.path().string(); - // Cargar temporalmente para obtener dimensiones - auto temp_texture = std::make_shared(renderer_, fullpath); - int width = temp_texture->getWidth(); + // Cargar textura y obtener dimensiones + auto texture = std::make_shared(renderer_, fullpath); + int width = texture->getWidth(); - texture_files.push_back({filename, fullpath, width}); + texture_files.push_back({filename, texture, width}); } } @@ -172,9 +172,9 @@ bool Engine::initialize(int width, int height, int zoom, bool fullscreen) { return a.width > b.width; // Descendente por tamaño }); - // Cargar todas las texturas en orden de tamaño (0=big, 1=normal, 2=small, 3=tiny) + // Guardar texturas ya cargadas en orden (0=big, 1=normal, 2=small, 3=tiny) for (const auto& info : texture_files) { - textures_.push_back(std::make_shared(renderer_, info.path)); + textures_.push_back(info.texture); texture_names_.push_back(info.name); } }