Cambiados los printf por std::cout

This commit is contained in:
2022-12-07 09:12:30 +01:00
parent 6aebb28f37
commit 7adb049b37
2 changed files with 21 additions and 20 deletions

View File

@@ -589,13 +589,13 @@ bool Game::loadScoreFile()
// El fichero no existe // El fichero no existe
if (file == nullptr) 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 // Creamos el fichero para escritura
file = SDL_RWFromFile(p.c_str(), "w+b"); file = SDL_RWFromFile(p.c_str(), "w+b");
if (file != nullptr) 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 // Inicializamos los datos
for (int i = 0; i < TOTAL_SCORE_DATA; ++i) for (int i = 0; i < TOTAL_SCORE_DATA; ++i)
@@ -609,7 +609,7 @@ bool Game::loadScoreFile()
} }
else 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; success = false;
} }
} }
@@ -617,7 +617,7 @@ bool Game::loadScoreFile()
else else
{ {
// Cargamos los datos // 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) for (int i = 0; i < TOTAL_SCORE_DATA; ++i)
SDL_RWread(file, &scoreDataFile[i], sizeof(Uint32), 1); SDL_RWread(file, &scoreDataFile[i], sizeof(Uint32), 1);
@@ -655,13 +655,13 @@ bool Game::loadDemoFile()
// El fichero no existe // El fichero no existe
if (file == nullptr) 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 // Creamos el fichero para escritura
file = SDL_RWFromFile(p.c_str(), "w+b"); file = SDL_RWFromFile(p.c_str(), "w+b");
if (file != nullptr) 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 // Inicializamos los datos
for (int i = 0; i < TOTAL_DEMO_DATA; ++i) for (int i = 0; i < TOTAL_DEMO_DATA; ++i)
@@ -681,7 +681,7 @@ bool Game::loadDemoFile()
} }
else 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; success = false;
} }
} }
@@ -689,7 +689,7 @@ bool Game::loadDemoFile()
else else
{ {
// Cargamos los datos // 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) for (int i = 0; i < TOTAL_DEMO_DATA; ++i)
SDL_RWread(file, &demo.dataFile[i], sizeof(demoKeys_t), 1); 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); 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 // Cerramos el fichero
SDL_RWclose(file); SDL_RWclose(file);
} }
else 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; return success;
} }
@@ -771,14 +771,14 @@ bool Game::saveDemoFile()
SDL_RWwrite(file, &demo.dataFile[i], sizeof(demoKeys_t), 1); 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 // Cerramos el fichero
SDL_RWclose(file); SDL_RWclose(file);
} }
else 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; return success;
@@ -1806,7 +1806,7 @@ void Game::updateDeath()
{ {
// Hace sonar aleatoriamente uno de los 4 sonidos de burbujas // Hace sonar aleatoriamente uno de los 4 sonidos de burbujas
const Uint8 index = rand() % 4; 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); JA_PlaySound(sound[index], 0);
} }
} }

View File

@@ -1025,8 +1025,8 @@ bool Title::updatePlayerInputs(int numPlayer)
} }
else else
{ // Si hay mas de un dispositivo, se recorre el vector { // Si hay mas de un dispositivo, se recorre el vector
printf("numplayer:%i\n", numPlayer); std::cout << "numplayer:" << numPlayer << std::endl;
printf("deviceindex:%i\n", deviceIndex.at(numPlayer)); std::cout << "deviceindex:" << deviceIndex.at(numPlayer) << std::endl;
// Incrementa el indice // Incrementa el indice
if (deviceIndex.at(numPlayer) < numDevices - 1) if (deviceIndex.at(numPlayer) < numDevices - 1)
@@ -1037,7 +1037,7 @@ bool Title::updatePlayerInputs(int numPlayer)
{ {
deviceIndex.at(numPlayer) = 0; 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 // Si coincide con el del otro jugador, se lo intercambian
if (deviceIndex.at(0) == deviceIndex.at(1)) 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); background = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH * 2, GAMECANVAS_HEIGHT * 2);
if (background == nullptr) 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 // 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 // Comprueba cuantos mandos hay conectados para gestionar el menu de opciones
void Title::checkInputDevices() void Title::checkInputDevices()
{ {
printf("Filling devices for options menu...\n"); std::cout << "Filling devices for options menu..." << std::endl;
input->discoverGameController(); input->discoverGameController();
const int numControllers = input->getNumControllers(); const int numControllers = input->getNumControllers();
availableInputDevices.clear(); availableInputDevices.clear();
@@ -1115,7 +1115,7 @@ void Title::checkInputDevices()
temp.name = input->getControllerName(i); temp.name = input->getControllerName(i);
temp.deviceType = INPUT_USE_GAMECONTROLLER; temp.deviceType = INPUT_USE_GAMECONTROLLER;
availableInputDevices.push_back(temp); 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 // Añade el teclado al final
@@ -1123,7 +1123,8 @@ void Title::checkInputDevices()
temp.name = "KEYBOARD"; temp.name = "KEYBOARD";
temp.deviceType = INPUT_USE_KEYBOARD; temp.deviceType = INPUT_USE_KEYBOARD;
availableInputDevices.push_back(temp); 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 // Recarga las texturas