Trabajando en el menu del titulo

This commit is contained in:
2022-08-24 22:39:36 +02:00
parent 1f4d094593
commit a0613ddd8d
9 changed files with 126 additions and 113 deletions

View File

@@ -56,12 +56,16 @@ void Text::init()
mOffset[i].x = ((i - 32) % 15) * mBoxWidth;
mOffset[i].y = ((i - 32) / 15) * mBoxHeight;
}
printf("Cargando %s\n", mFile.c_str());
const std::string texto = "w = "+ std::to_string(mBoxWidth) + ", h = " + std::to_string(mBoxHeight);
printf("%s\n",texto.c_str());
}
// Escribe texto en pantalla
void Text::write(int x, int y, std::string text, int kerning, int lenght)
{
Uint16 shift = 0;
int shift = 0;
if (lenght == -1)
lenght = text.length();
@@ -134,14 +138,15 @@ void Text::writeDX(Uint8 flags, int x, int y, std::string text, int kerning, col
}
// Obtiene la longitud en pixels de una cadena
Uint16 Text::lenght(std::string text, int kerning)
int Text::lenght(std::string text, int kerning)
{
Uint16 shift = 0;
int shift = 0;
for (int i = 0; i < (int)text.length(); ++i)
for (int i = 0; i < (int)text.length(); i++)
shift += (mOffset[int(text[i])].w + kerning);
return shift;
// Descuenta el kerning del último caracter
return shift - kerning;
}
// Inicializa el vector de offsets desde un fichero
@@ -178,7 +183,7 @@ void Text::initOffsetFromFile()
}
// Devuelve el valor de la variable
Uint8 Text::getCharacterWidth()
int Text::getCharacterWidth()
{
return mBoxWidth;
}