2021-06-09 14:08:58 -04:00
|
|
|
#include "classicsprite.h"
|
|
|
|
#include <SFML/Graphics/RenderTarget.hpp>
|
|
|
|
|
2021-10-04 10:20:24 -04:00
|
|
|
ClassicSprite::ClassicSprite(const sf::RectangleShape& shape) :
|
2021-06-16 13:11:00 -04:00
|
|
|
_prototype(shape),
|
2021-06-11 12:58:44 -04:00
|
|
|
_shape(shape),
|
2021-10-04 10:20:24 -04:00
|
|
|
_trail(shape)
|
|
|
|
{}
|
2021-06-09 14:08:58 -04:00
|
|
|
|
|
|
|
void ClassicSprite::draw(sf::RenderTarget& target, sf::RenderStates states) const
|
|
|
|
{
|
|
|
|
target.draw(_shape, states);
|
2021-06-11 12:58:44 -04:00
|
|
|
target.draw(_trail, states);
|
2021-06-09 14:08:58 -04:00
|
|
|
}
|
|
|
|
|
2021-06-16 11:16:18 -04:00
|
|
|
void ClassicSprite::reset()
|
|
|
|
{
|
|
|
|
_shape.setPosition(0, 0);
|
|
|
|
_trail.setPosition(0, 0);
|
2021-06-16 13:11:00 -04:00
|
|
|
|
|
|
|
_shape = _prototype;
|
|
|
|
_trail = _prototype;
|
2021-06-16 11:16:18 -04:00
|
|
|
}
|
|
|
|
|
2021-10-04 10:20:24 -04:00
|
|
|
void ClassicSprite::setCoordinates(const Coordinates& coordinates)
|
2021-06-09 14:08:58 -04:00
|
|
|
{
|
2021-06-24 14:04:09 -04:00
|
|
|
_shape.setPosition(coordinates.x, coordinates.y);
|
2021-10-04 10:20:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void ClassicSprite::setTrailCoordinates(const Coordinates &coordinates)
|
|
|
|
{
|
|
|
|
_trail.setPosition(coordinates.x, coordinates.y);
|
2021-06-11 12:58:44 -04:00
|
|
|
}
|
|
|
|
|
2021-06-24 14:04:09 -04:00
|
|
|
Coordinates ClassicSprite::coordinates() const
|
2021-06-23 18:43:13 -04:00
|
|
|
{
|
2021-06-24 14:04:09 -04:00
|
|
|
return {_shape.getPosition().x, _shape.getPosition().y};
|
2021-06-23 18:43:13 -04:00
|
|
|
}
|
|
|
|
|
2021-07-14 22:45:52 -04:00
|
|
|
Coordinates ClassicSprite::trailCoordinates() const
|
|
|
|
{
|
|
|
|
return {_trail.getPosition().x, _trail.getPosition().y};
|
|
|
|
}
|
|
|
|
|
2021-10-04 10:20:24 -04:00
|
|
|
void ClassicSprite::setColor(const sf::Color& color)
|
2021-06-16 11:16:18 -04:00
|
|
|
{
|
2021-10-04 10:20:24 -04:00
|
|
|
_shape.setFillColor(color);
|
2021-06-11 13:39:47 -04:00
|
|
|
}
|
|
|
|
|
2021-10-04 10:20:24 -04:00
|
|
|
void ClassicSprite::setTrailColor(const sf::Color& color)
|
2021-06-11 13:39:47 -04:00
|
|
|
{
|
2021-10-04 10:20:24 -04:00
|
|
|
_trail.setFillColor(color);
|
2021-06-11 13:39:47 -04:00
|
|
|
}
|
|
|
|
|
2021-10-04 10:20:24 -04:00
|
|
|
sf::Color ClassicSprite::color() const
|
2021-06-17 15:13:25 -04:00
|
|
|
{
|
2021-10-04 10:20:24 -04:00
|
|
|
return _shape.getFillColor();
|
2021-06-17 15:13:25 -04:00
|
|
|
}
|
|
|
|
|
2021-10-04 10:20:24 -04:00
|
|
|
sf::Color ClassicSprite::trailColor() const
|
2021-06-11 13:39:47 -04:00
|
|
|
{
|
2021-10-04 10:20:24 -04:00
|
|
|
return _trail.getFillColor();
|
2021-06-09 14:08:58 -04:00
|
|
|
}
|