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