#include "spritesfml.h"

SpriteSFML::SpriteSFML(sf::RenderTarget * const render_target,
                       const std::shared_ptr<sf::Texture>& texture,
                       const kku::Area<unsigned int> &cropping) :
    _render_target(render_target),
    _sprite(*texture, sf::IntRect(cropping.left, cropping.top, cropping.width, cropping.height))
{}

void SpriteSFML::setPosition(const kku::Point& position)
{
    _sprite.setPosition(position.x, position.y);
}

kku::Point SpriteSFML::getPosition() const
{
    const auto& position = _sprite.getPosition();
    return kku::Point
    {
        position.x,
        position.y
    };
}

void SpriteSFML::move(const kku::Vector2<float>& delta)
{
    _sprite.move({delta.first, delta.second});
}

void SpriteSFML::display() const
{
    _render_target->draw(_sprite);
}
