From 7adb049b37bc0c085641fea51284680c2bb555bb Mon Sep 17 00:00:00 2001 From: Sergio Valor Martinez Date: Wed, 7 Dec 2022 09:12:30 +0100 Subject: [PATCH] Cambiados los printf por std::cout --- source/game.cpp | 26 +++++++++++++------------- source/title.cpp | 15 ++++++++------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/source/game.cpp b/source/game.cpp index 417d054..129b62d 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -589,13 +589,13 @@ bool Game::loadScoreFile() // El fichero no existe if (file == nullptr) { - printf("Warning: Unable to open %s file\n", filename.c_str()); + std::cout << "Warning: Unable to open " << filename.c_str() << " file" << std::endl; // Creamos el fichero para escritura file = SDL_RWFromFile(p.c_str(), "w+b"); if (file != nullptr) { - printf("New file (%s) created!\n", filename.c_str()); + std::cout << "New file (" << filename.c_str() << ") created!" << std::endl; // Inicializamos los datos for (int i = 0; i < TOTAL_SCORE_DATA; ++i) @@ -609,7 +609,7 @@ bool Game::loadScoreFile() } else { - printf("Error: Unable to create file %s\n", filename.c_str()); + std::cout << "Error: Unable to create file " << filename.c_str() << std::endl; success = false; } } @@ -617,7 +617,7 @@ bool Game::loadScoreFile() else { // Cargamos los datos - printf("Reading file %s\n", filename.c_str()); + std::cout << "Reading file " << filename.c_str() << std::endl; for (int i = 0; i < TOTAL_SCORE_DATA; ++i) SDL_RWread(file, &scoreDataFile[i], sizeof(Uint32), 1); @@ -655,13 +655,13 @@ bool Game::loadDemoFile() // El fichero no existe if (file == nullptr) { - printf("Warning: Unable to open %s file\n", filename.c_str()); + std::cout << "Warning: Unable to open " << filename.c_str() << " file" << std::endl; // Creamos el fichero para escritura file = SDL_RWFromFile(p.c_str(), "w+b"); if (file != nullptr) { - printf("New file (%s) created!\n", filename.c_str()); + std::cout << "New file (" << filename.c_str() << ") created!" << std::endl; // Inicializamos los datos for (int i = 0; i < TOTAL_DEMO_DATA; ++i) @@ -681,7 +681,7 @@ bool Game::loadDemoFile() } else { - printf("Error: Unable to create file %s\n", filename.c_str()); + std::cout << "Error: Unable to create file " << filename.c_str() << std::endl; success = false; } } @@ -689,7 +689,7 @@ bool Game::loadDemoFile() else { // Cargamos los datos - printf("Reading file %s\n", filename.c_str()); + std::cout << "Reading file " << filename.c_str() << std::endl; for (int i = 0; i < TOTAL_DEMO_DATA; ++i) SDL_RWread(file, &demo.dataFile[i], sizeof(demoKeys_t), 1); @@ -715,14 +715,14 @@ bool Game::saveScoreFile() SDL_RWwrite(file, &scoreDataFile[i], sizeof(Uint32), 1); } - printf("Writing file %s\n", filename.c_str()); + std::cout << "Writing file " << filename.c_str() << std::endl; // Cerramos el fichero SDL_RWclose(file); } else { - printf("Error: Unable to save %s file! %s\n", filename.c_str(), SDL_GetError()); + std::cout << "Error: Unable to save " << filename.c_str() << " file! " << SDL_GetError() << std::endl; } return success; } @@ -771,14 +771,14 @@ bool Game::saveDemoFile() SDL_RWwrite(file, &demo.dataFile[i], sizeof(demoKeys_t), 1); } - printf("Writing file %s\n", filename.c_str()); + std::cout << "Writing file " << filename.c_str() << std::endl; // Cerramos el fichero SDL_RWclose(file); } else { - printf("Error: Unable to save %s file! %s\n", filename.c_str(), SDL_GetError()); + std::cout << "Error: Unable to save " << filename.c_str() << " file! " << SDL_GetError() << std::endl; } } return success; @@ -1806,7 +1806,7 @@ void Game::updateDeath() { // Hace sonar aleatoriamente uno de los 4 sonidos de burbujas const Uint8 index = rand() % 4; - JA_Sound_t* sound[4] = {bubble1Sound, bubble2Sound, bubble3Sound, bubble4Sound}; + JA_Sound_t *sound[4] = {bubble1Sound, bubble2Sound, bubble3Sound, bubble4Sound}; JA_PlaySound(sound[index], 0); } } diff --git a/source/title.cpp b/source/title.cpp index f7023f8..fab408f 100644 --- a/source/title.cpp +++ b/source/title.cpp @@ -1025,8 +1025,8 @@ bool Title::updatePlayerInputs(int numPlayer) } else { // Si hay mas de un dispositivo, se recorre el vector - printf("numplayer:%i\n", numPlayer); - printf("deviceindex:%i\n", deviceIndex.at(numPlayer)); + std::cout << "numplayer:" << numPlayer << std::endl; + std::cout << "deviceindex:" << deviceIndex.at(numPlayer) << std::endl; // Incrementa el indice if (deviceIndex.at(numPlayer) < numDevices - 1) @@ -1037,7 +1037,7 @@ bool Title::updatePlayerInputs(int numPlayer) { deviceIndex.at(numPlayer) = 0; } - printf("deviceindex:%i\n", deviceIndex.at(numPlayer)); + std::cout << "deviceindex:" << deviceIndex.at(numPlayer) << std::endl; // Si coincide con el del otro jugador, se lo intercambian if (deviceIndex.at(0) == deviceIndex.at(1)) @@ -1065,7 +1065,7 @@ void Title::createTiledBackground() background = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH * 2, GAMECANVAS_HEIGHT * 2); if (background == nullptr) { - printf("TitleSurface could not be created!\nSDL Error: %s\n", SDL_GetError()); + std::cout << "TitleSurface could not be created!\nSDL Error: " << SDL_GetError() << std::endl; } // Crea los objetos para pintar en la textura de fondo @@ -1101,7 +1101,7 @@ void Title::createTiledBackground() // Comprueba cuantos mandos hay conectados para gestionar el menu de opciones void Title::checkInputDevices() { - printf("Filling devices for options menu...\n"); + std::cout << "Filling devices for options menu..." << std::endl; input->discoverGameController(); const int numControllers = input->getNumControllers(); availableInputDevices.clear(); @@ -1115,7 +1115,7 @@ void Title::checkInputDevices() temp.name = input->getControllerName(i); temp.deviceType = INPUT_USE_GAMECONTROLLER; availableInputDevices.push_back(temp); - printf("Device %i:\t%s\n", (int)availableInputDevices.size(), temp.name.c_str()); + std::cout << "Device " << (int)availableInputDevices.size() << " - " << temp.name.c_str() << std::endl; } // AƱade el teclado al final @@ -1123,7 +1123,8 @@ void Title::checkInputDevices() temp.name = "KEYBOARD"; temp.deviceType = INPUT_USE_KEYBOARD; availableInputDevices.push_back(temp); - printf("Device %i:\t%s\n\n", (int)availableInputDevices.size(), temp.name.c_str()); + std::cout << "Device " << (int)availableInputDevices.size() << " - " << temp.name.c_str() << std::endl; + std::cout << std::endl; } // Recarga las texturas