Quitados todos los printf menos uno

This commit is contained in:
2022-10-30 22:48:50 +01:00
parent 531ac94bc0
commit 2e0b0f32b5
7 changed files with 49 additions and 53 deletions

View File

@@ -73,7 +73,7 @@ animatedSprite_t loadAnimationFromFile(Texture *texture, std::string filePath)
else
{
printf("Warning: file %s, unknown parameter \"%s\"\n", filename.c_str(), line.substr(0, pos).c_str());
std::cout << "Warning: file " << filename.c_str() << "\n, unknown parameter \"" << line.substr(0, pos).c_str() << "\"" << std::endl;
}
}
} while (line != "[/animation]");
@@ -108,7 +108,7 @@ animatedSprite_t loadAnimationFromFile(Texture *texture, std::string filePath)
else
{
printf("Warning: file %s, unknown parameter \"%s\"\n", filename.c_str(), line.substr(0, pos).c_str());
std::cout << "Warning: file " << filename.c_str() << "\n, unknown parameter \"" << line.substr(0, pos).c_str() << "\"" << std::endl;
}
// Normaliza valores
@@ -133,7 +133,7 @@ animatedSprite_t loadAnimationFromFile(Texture *texture, std::string filePath)
// El fichero no se puede abrir
else
{
printf("Warning: Unable to open %s file\n", filename.c_str());
std::cout << "Warning: Unable to open " << filename.c_str() << " file" << std::endl;
}
// Pone un valor por defecto
@@ -212,7 +212,7 @@ int AnimatedSprite::getIndex(std::string name)
}
}
printf("** Warning: could not find \"%s\" animation\n", name.c_str());
std::cout << "** Warning: could not find \"" << name.c_str() << "\" animation" << std::endl;
return -1;
}
@@ -409,7 +409,7 @@ animatedSprite_t AnimatedSprite::loadFromFile(std::string filePath)
else
{
printf("Warning: file %s, unknown parameter \"%s\"\n", filename.c_str(), line.substr(0, pos).c_str());
std::cout << "Warning: file " << filename.c_str() << "\n, unknown parameter \"" << line.substr(0, pos).c_str() << "\"" << std::endl;
}
}
} while (line != "[/animation]");
@@ -445,7 +445,7 @@ animatedSprite_t AnimatedSprite::loadFromFile(std::string filePath)
else
{
printf("Warning: file %s, unknown parameter \"%s\"\n", filename.c_str(), line.substr(0, pos).c_str());
std::cout << "Warning: file " << filename.c_str() << "\n, unknown parameter \"" << line.substr(0, pos).c_str() << "\"" << std::endl;
}
// Normaliza valores
@@ -470,7 +470,7 @@ animatedSprite_t AnimatedSprite::loadFromFile(std::string filePath)
// El fichero no se puede abrir
else
{
printf("Warning: Unable to open %s file\n", filename.c_str());
std::cout << "Warning: Unable to open " << filename.c_str() << " file" << std::endl;
}
// Pone un valor por defecto

View File

@@ -1,4 +1,5 @@
#include "asset.h"
#include <iostream>
// Constructor
Asset::Asset(std::string path)
@@ -31,7 +32,7 @@ std::string Asset::get(std::string text)
}
}
printf("Warning: file %s not found\n", text.c_str());
std::cout << "Warning: file " << text.c_str() << " not found" << std::endl;
return "";
}
@@ -40,7 +41,7 @@ bool Asset::check()
{
bool success = true;
printf("\n** Checking files.\n");
std::cout << "\n** Checking files." << std::endl;
// Comprueba la lista de ficheros clasificandolos por tipo
for (int type = 0; type < t_maxAssetType; ++type)
@@ -59,7 +60,7 @@ bool Asset::check()
// Si hay ficheros de ese tipo, comprueba si existen
if (any)
{
printf("\n>> %s FILES\n", getTypeName(type).c_str());
std::cout << "\n>> " << getTypeName(type).c_str() << " FILES" << std::endl;
for (auto f : fileList)
{
@@ -74,11 +75,13 @@ bool Asset::check()
// Resultado
if (success)
{
printf("\n** All files OK.\n\n");
std::cout << "\n** All files OK.\n"
<< std::endl;
}
else
{
printf("\n** A file is missing. Exiting.\n\n");
std::cout << "\n** A file is missing. Exiting.\n"
<< std::endl;
}
return success;

View File

@@ -107,7 +107,7 @@ bool Menu::load(std::string file_path)
if (file.good())
{
// Procesa el fichero linea a linea
printf("Reading file %s\n", filename.c_str());
std::cout << "Reading file " << filename.c_str() << std::endl;
while (std::getline(file, line))
{
if (line == "[item]")
@@ -130,7 +130,7 @@ bool Menu::load(std::string file_path)
// Procesa las dos subcadenas
if (!setItem(&item, line.substr(0, pos), line.substr(pos + 1, line.length())))
{
printf("Warning: file %s\n, unknown parameter \"%s\"\n", filename.c_str(), line.substr(0, pos).c_str());
std::cout << "Warning: file " << filename.c_str() << "\n, unknown parameter \"" << line.substr(0, pos).c_str() << "\"" << std::endl;
success = false;
}
@@ -147,7 +147,7 @@ bool Menu::load(std::string file_path)
// Procesa las dos subcadenas
if (!setVars(line.substr(0, pos), line.substr(pos + 1, line.length())))
{
printf("Warning: file %s, unknown parameter \"%s\"\n", filename.c_str(), line.substr(0, pos).c_str());
std::cout << "Warning: file " << filename.c_str() << "\n, unknown parameter \"" << line.substr(0, pos).c_str() << "\"" << std::endl;
success = false;
}
@@ -161,13 +161,13 @@ bool Menu::load(std::string file_path)
}
// Cierra el fichero
printf("Closing file %s\n", filename.c_str());
std::cout << "Closing file " << filename.c_str() << std::endl;
file.close();
}
// El fichero no se puede abrir
else
{
printf("Warning: Unable to open %s file\n", filename.c_str());
std::cout << "Warning: Unable to open " << filename.c_str() << " file" << std::endl;
success = false;
}

View File

@@ -50,14 +50,14 @@ textFile_t LoadTextFile(std::string file)
};
// Cierra el fichero
printf("Text loaded: %s\n", filename.c_str());
std::cout << "Text loaded: " << filename.c_str() << std::endl;
rfile.close();
}
// El fichero no se puede abrir
else
{
printf("Warning: Unable to open %s file\n", filename.c_str());
std::cout << "Warning: Unable to open " << filename.c_str() << " file" << std::endl;
}
// Establece las coordenadas para cada caracter ascii de la cadena y su ancho
@@ -243,14 +243,14 @@ void Text::initOffsetFromFile(std::string file)
};
// Cierra el fichero
printf("Text loaded: %s\n", filename.c_str());
std::cout << "Text loaded: " << filename.c_str() << std::endl;
rfile.close();
}
// El fichero no se puede abrir
else
{
printf("Warning: Unable to open %s file\n", filename.c_str());
std::cout << "Warning: Unable to open " << filename.c_str() << " file" << std::endl;
}
// Establece las coordenadas para cada caracter ascii de la cadena y su ancho

View File

@@ -2,6 +2,7 @@
#include "texture.h"
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
#include <iostream>
// Constructor
Texture::Texture(SDL_Renderer *renderer, std::string path)
@@ -43,7 +44,7 @@ bool Texture::loadFromFile(std::string path, SDL_Renderer *renderer)
}
else
{
printf("Image loaded: %s\n", filename.c_str());
std::cout << "Image loaded: " << filename.c_str() << std::endl;
}
int depth, pitch;
@@ -71,7 +72,7 @@ bool Texture::loadFromFile(std::string path, SDL_Renderer *renderer)
SDL_Surface *loadedSurface = SDL_CreateRGBSurfaceWithFormatFrom((void *)data, width, height, depth, pitch, pixel_format);
if (loadedSurface == nullptr)
{
printf("Unable to load image %s!\n", path.c_str());
std::cout << "Unable to load image " << path.c_str() << std::endl;
}
else
{
@@ -79,7 +80,7 @@ bool Texture::loadFromFile(std::string path, SDL_Renderer *renderer)
newTexture = SDL_CreateTextureFromSurface(renderer, loadedSurface);
if (newTexture == nullptr)
{
printf("Unable to create texture from %s! SDL Error: %s\n", path.c_str(), SDL_GetError());
std::cout << "Unable to create texture from " << path.c_str() << "! SDL Error: " << SDL_GetError() << std::endl;
}
else
{
@@ -104,7 +105,7 @@ bool Texture::createBlank(SDL_Renderer *renderer, int width, int height, SDL_Tex
texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, access, width, height);
if (texture == nullptr)
{
printf("Unable to create blank texture! SDL Error: %s\n", SDL_GetError());
std::cout << "Unable to create blank texture! SDL Error: " << SDL_GetError() << std::endl;
}
else
{

View File

@@ -990,8 +990,7 @@ void Director::setSection(section_t section)
// Ejecuta la seccion de juego con el logo
void Director::runLogo()
{
std::cout << std::endl
<< "* SECTION: LOGO" << std::endl;
std::cout << "\n* SECTION: LOGO" << std::endl;
loadResources(section);
logo = new Logo(renderer, screen, resource, asset, options, section.subsection);
setSection(logo->run());
@@ -1002,8 +1001,7 @@ void Director::runLogo()
// Ejecuta la seccion de juego de la introducción
void Director::runIntro()
{
std::cout << std::endl
<< "* SECTION: INTRO" << std::endl;
std::cout << "\n* SECTION: INTRO" << std::endl;
loadResources(section);
intro = new Intro(renderer, screen, resource, asset, options);
setSection(intro->run());
@@ -1014,8 +1012,7 @@ void Director::runIntro()
// Ejecuta la seccion de juego con el titulo y los menus
void Director::runTitle()
{
std::cout << std::endl
<< "* SECTION: TITLE" << std::endl;
std::cout << "\n* SECTION: TITLE" << std::endl;
if ((JA_GetMusicState() == JA_MUSIC_INVALID) || (JA_GetMusicState() == JA_MUSIC_STOPPED))
{
JA_PlayMusic(music);
@@ -1030,8 +1027,7 @@ void Director::runTitle()
// Ejecuta la seccion de los creditos del juego
void Director::runCredits()
{
std::cout << std::endl
<< "* SECTION: CREDITS" << std::endl;
std::cout << "\n* SECTION: CREDITS" << std::endl;
loadResources(section);
credits = new Credits(renderer, screen, resource, asset, options);
setSection(credits->run());
@@ -1042,8 +1038,7 @@ void Director::runCredits()
// Ejecuta la seccion de la demo, donde se ven pantallas del juego
void Director::runDemo()
{
std::cout << std::endl
<< "* SECTION: DEMO" << std::endl;
std::cout << "\n* SECTION: DEMO" << std::endl;
loadResources(section);
demo = new Demo(renderer, screen, resource, asset, options, debug);
setSection(demo->run());
@@ -1054,8 +1049,7 @@ void Director::runDemo()
// Ejecuta la seccion de juego donde se juega
void Director::runGame()
{
std::cout << std::endl
<< "* SECTION: GAME" << std::endl;
std::cout << "\n* SECTION: GAME" << std::endl;
JA_StopMusic();
loadResources(section);
game = new Game(renderer, screen, resource, asset, options, input, debug);

View File

@@ -15,8 +15,6 @@ std::vector<int> loadRoomTileFile(std::string file_path)
if (file.good())
{
// Procesa el fichero linea a linea
// printf("Reading file %s\n", filename.c_str());
while (std::getline(file, line))
{ // Lee el fichero linea a linea
if (line.find("data encoding") != std::string::npos)
@@ -39,13 +37,13 @@ std::vector<int> loadRoomTileFile(std::string file_path)
}
// Cierra el fichero
printf("TileMap loaded: %s\n", filename.c_str());
std::cout << "TileMap loaded: " << filename.c_str() << std::endl;
file.close();
}
else
{ // El fichero no se puede abrir
printf("Warning: Unable to open %s file\n", filename.c_str());
std::cout << "Warning: Unable to open " << filename.c_str() << " file" << std::endl;
}
return tileMapFile;
@@ -86,7 +84,7 @@ room_t loadRoomFile(std::string file_path)
// Procesa las dos subcadenas
if (!setEnemy(&enemy, line.substr(0, pos), line.substr(pos + 1, line.length())))
{
printf("Warning: file %s\n, unknown parameter \"%s\"\n", filename.c_str(), line.substr(0, pos).c_str());
std::cout << "Warning: file " << filename.c_str() << "\n, unknown parameter \"" << line.substr(0, pos).c_str() << "\"" << std::endl;
}
} while (line != "[/enemy]");
@@ -112,7 +110,7 @@ room_t loadRoomFile(std::string file_path)
// Procesa las dos subcadenas
if (!setItem(&item, line.substr(0, pos), line.substr(pos + 1, line.length())))
{
printf("Warning: file %s\n, unknown parameter \"%s\"\n", filename.c_str(), line.substr(0, pos).c_str());
std::cout << "Warning: file " << filename.c_str() << "\n, unknown parameter \"" << line.substr(0, pos).c_str() << "\"" << std::endl;
}
} while (line != "[/item]");
@@ -129,19 +127,19 @@ room_t loadRoomFile(std::string file_path)
// Procesa las dos subcadenas
if (!setVars(&room, line.substr(0, pos), line.substr(pos + 1, line.length())))
{
printf("Warning: file %s, unknown parameter \"%s\"\n", filename.c_str(), line.substr(0, pos).c_str());
std::cout << "Warning: file " << filename.c_str() << "\n, unknown parameter \"" << line.substr(0, pos).c_str() << "\"" << std::endl;
}
}
}
// Cierra el fichero
printf("Room loaded: %s\n", filename.c_str());
std::cout << "Room loaded: " << filename.c_str() << std::endl;
file.close();
}
// El fichero no se puede abrir
else
{
printf("Warning: Unable to open %s file\n", filename.c_str());
std::cout << "Warning: Unable to open " << filename.c_str() << " file" << std::endl;
}
return room;
@@ -435,7 +433,7 @@ Room::Room(room_t *room, SDL_Renderer *renderer, Screen *screen, Asset *asset, o
mapTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT);
if (mapTexture == nullptr)
{
printf("Error: mapTexture could not be created!\nSDL Error: %s\n", SDL_GetError());
std::cout << "Error: mapTexture could not be created!\nSDL Error: " << SDL_GetError() << std::endl;
}
SDL_SetTextureBlendMode(mapTexture, SDL_BLENDMODE_BLEND);