#include "text.h"

Text::Text(TTF_Font* font, SDL_Color color)
{
    this->font = font;
    this->color = color;
}

void Text::draw(SDL_Renderer* renderer, std::string text, int x, int y)
{
    surface = TTF_RenderText_Solid(font, text.c_str(), color);
    texture = SDL_CreateTextureFromSurface(renderer, surface);
    rect = { x, y, surface->w, surface->h };
    SDL_RenderCopy(renderer, texture, NULL, &rect);
    SDL_FreeSurface(surface);
    SDL_DestroyTexture(texture);
}