#include "text.h"

Text::Text(TTF_Font *TexttextFont)
{
    textFont = TexttextFont;
}

Text::Text(std::string newText, TTF_Font *TexttextFont)
{
    textFont = TexttextFont;
    change(newText);
}

int Text::getW() const
{
    return textImage->w;
}

int Text::getH() const
{
    return textImage->h;
}

void Text::change(std::string newText)
{
    textImage = TTF_RenderText_Solid(textFont, newText.c_str(), defaultFontColor);
}

void Text::draw(int x, int y, bool centerX, bool centerY) const
{
    SDL_Rect offset;
    offset.x = x - centerX * textImage->w / 2;
    offset.y = y - centerY * textImage->h / 2;

    SDL_BlitSurface(textImage, NULL, screen, &offset);
}
