Files
volcano_2022/source/text.h

67 lines
1.5 KiB
C++

#pragma once
#include "sprite.h"
#ifndef TEXT_H
#define TEXT_H
// Clase texto. Pinta texto en pantalla a partir de un bitmap
class Text
{
public:
// Constructor
Text();
// Destructor
~Text();
// Inicializador
void init(LTexture *texture, SDL_Renderer *renderer, Uint8 type, Uint8 size);
// Escribe el texto en pantalla
void write(int x, int y, std::string text);
void write(int x, int y, std::string text, int kerning);
void write(int x, int y, std::string text, int kerning, Uint8 lenght);
// Escribe el texto con colores
void writeColored(int x, int y, std::string text, Uint8 R, Uint8 G, Uint8 B);
// Escribe el texto centrado en un punto x y con kerning
void writeCentered(int x, int y, std::string text, int kerning);
// Obtiene la longitud en pixels de una cadena
Uint16 lenght(std::string text, int kerning);
// Obtiene el valor de la variable
Uint8 getType();
// Establece el valor de la variable
void setType(Uint8 type);
// Obtiene el valor de la variable
Uint8 getSize();
// Establece el valor de la variable
void setSize(Uint8 size);
private:
// Objeto con los graficos para el texto
Sprite *mSprite;
// Coordenadas dentro del PNG para cada código ascii y su anchura
struct Offset
{
int x;
int y;
Uint8 w;
};
// Vector con las posiciones y ancho de cada letra
Offset mOffset[255];
// Indica si el texto es de anchura fija o variable
Uint8 mType;
Uint8 mSize;
};
#endif