project-kyoku/modes/classicmode/game/classicsprite.cpp

64 lines
1.3 KiB
C++
Raw Normal View History

#include "classicsprite.h"
#include <SFML/Graphics/RenderTarget.hpp>
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),
_trail(shape)
{}
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);
}
void ClassicSprite::reset()
{
_shape.setPosition(0, 0);
_trail.setPosition(0, 0);
2021-06-16 19:11:00 +02:00
_shape = _prototype;
_trail = _prototype;
}
void ClassicSprite::setCoordinates(const Coordinates& coordinates)
{
_shape.setPosition(coordinates.x, coordinates.y);
}
void ClassicSprite::setTrailCoordinates(const Coordinates &coordinates)
{
_trail.setPosition(coordinates.x, coordinates.y);
2021-06-11 18:58:44 +02:00
}
Coordinates ClassicSprite::coordinates() const
2021-06-24 00:43:13 +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};
}
void ClassicSprite::setColor(const sf::Color& color)
{
_shape.setFillColor(color);
}
void ClassicSprite::setTrailColor(const sf::Color& color)
{
_trail.setFillColor(color);
}
sf::Color ClassicSprite::color() const
{
return _shape.getFillColor();
}
sf::Color ClassicSprite::trailColor() const
{
return _trail.getFillColor();
}