Trabajando en la carga de menus desde fichero

This commit is contained in:
2022-08-28 19:59:03 +02:00
parent d9cb7f68e2
commit d5a069b8db
9 changed files with 352 additions and 53 deletions

View File

@@ -9,8 +9,7 @@ Text::Text(std::string bitmapFile, std::string textFile, SDL_Renderer *renderer)
texture = new LTexture();
loadTextureFromFile(texture, bitmapFile, renderer);
SDL_Rect rect = {0,0,0,0};
mSprite = new Sprite(rect, texture, renderer);
mSprite = new Sprite({0, 0, 0, 0}, texture, renderer);
mSprite->setTexture(texture);
mSprite->setRenderer(renderer);
file = textFile;
@@ -57,9 +56,9 @@ void Text::init()
offset[i].y = ((i - 32) / 15) * boxHeight;
}
//printf("Cargando %s\n", file.c_str());
//const std::string texto = "w = "+ std::to_string(boxWidth) + ", h = " + std::to_string(boxHeight);
//printf("%s\n",texto.c_str());
// printf("Cargando %s\n", file.c_str());
// const std::string texto = "w = "+ std::to_string(boxWidth) + ", h = " + std::to_string(boxHeight);
// printf("%s\n",texto.c_str());
}
// Escribe texto en pantalla
@@ -124,7 +123,7 @@ void Text::writeDX(Uint8 flags, int x, int y, std::string text, int kerning, col
writeColored(x - shadowDistance, y + shadowDistance, text, shadowColor, kerning, lenght);
writeColored(x + shadowDistance, y - shadowDistance, text, shadowColor, kerning, lenght);
writeColored(x - shadowDistance, y - shadowDistance, text, shadowColor, kerning, lenght);
writeColored(x, y + shadowDistance, text, shadowColor, kerning, lenght);
writeColored(x, y - shadowDistance, text, shadowColor, kerning, lenght);
writeColored(x + shadowDistance, y, text, shadowColor, kerning, lenght);
@@ -174,7 +173,7 @@ void Text::initOffsetFromFile()
// Almacena solo las lineas impares
if (line_read % 2 == 1)
offset[index++].w = std::stoi(buffer);
// Limpia el buffer
buffer.clear();
line_read++;